﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using connect;
using Pharmacy_management_system;
using System.Collections;
using System.IO;
namespace Pharmacy_management_system
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.skinEngine1.SkinFile = "MP10.ssk";
            tabControl2.TabPages.Remove(tabPage9);
            tabControl2.TabPages.Remove(tabPage10);
            //tabControl9.TabPages.Remove(tabPage16);
            //tabControl9.TabPages.Remove(tabPage14);
            tabControl5.TabPages.Remove(tabPage18);
            tabControl5.TabPages.Remove(tabPage19);
            tabControl3.TabPages.Remove(tabPage12);
            tabControl3.TabPages.Remove(tabPage13);
            dny.Add(pingjia1_1); dny.Add(pingjia1_2); dny.Add(pingjia1_3); dny.Add(pingjia1_4);
            dny.Add(pingjia1_5); dny.Add(pingjia1_6); dny.Add(pingjia1_7); dny.Add(pingjia2_1);
            dny.Add(pingjia2_2); dny.Add(pingjia2_3); dny.Add(pingjia2_4); dny.Add(pingjia2_5);
            dny.Add(pingjia3_1); dny.Add(pingjia3_2); dny.Add(pingjia3_3);
        }
        public  string name1,name2,dept_name,title;
        public static string dept01;//要传到电子药历窗口或者调查表窗口
        public static string zuihoushuju = "  ";
        public static string yonghu = "";
        public static int i;
        public static string evl_question;
        public static string evl_allid;
        public static string cfz;
        public static bool mztype = false, zytype = false, chose1 = false, chose2 = false;
        string keshi = "", yisheng = "", zhenduan = "", yaopin = "", shumshouingcheng = "";
        ArrayList any = new ArrayList();
        ArrayList bny = new ArrayList();
        ArrayList cny = new ArrayList();
        ArrayList dny = new ArrayList();
        ArrayList eny = new ArrayList();
        string ht;
        int zhuangtai = 0, xh = 0, xh4 = 0;
        
        private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel5.Visible = false;
            linkLabel6.Visible = true;
            panel1.Visible = false;
        }

        private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            panel1.Visible = true;
            linkLabel5.Visible = false;
            linkLabel5.Visible = true;
            linkLabel6.Visible = false;
            
        }

        private void dateTimePicker4_ValueChanged(object sender, EventArgs e)
        {

        }
        private void tabPage10_Click(object sender, EventArgs e)
        {

        }
        private void label25_Click(object sender, EventArgs e)
        {

        }

        private void label24_Click(object sender, EventArgs e)
        {

        }

        private void dateTimePicker3_ValueChanged(object sender, EventArgs e)
        {

        }

        private void linkLabel8_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel8.Visible = false;
            linkLabel7.Visible = true;
            panel2.Visible = false;
        }

        private void linkLabel7_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel7.Visible = false;
            linkLabel8.Visible = true;
            panel2.Visible = true;
        }

        private void linkLabel10_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel10.Visible = false;
            linkLabel9.Visible = true;
            panel3.Visible = false;
        }

        private void linkLabel9_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel9.Visible = false;
            linkLabel10.Visible = true;
            panel3.Visible = true;
        }

        private void linkLabel11_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel11.Visible = false;
            linkLabel12.Visible = true;
            dataGridView3.Visible = false;
            label83.Visible = false;
        }

        private void linkLabel12_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel12.Visible = false;
            linkLabel11.Visible = true;
            dataGridView3.Visible = true;
            label83.Visible = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("科室", "筛选", radioButton1.Checked, "");
            ldo.ShowDialog();
            keshi = zuihoushuju;
            if (keshi.Trim() == "" || keshi == null) { }
            else { keshi = keshi.Substring(0, keshi.Length - 1); }
            richTextBox1.Text = keshi;
            zuihoushuju = "  ";
        }


        private void dataGridView4_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void panel5_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("医生", "  筛选", false, richTextBox1.Text);
            ldo.ShowDialog();
            yisheng = zuihoushuju;
            if (yisheng == "" || yisheng == null) { }
            else { yisheng = yisheng.Substring(0, yisheng.Length - 1); }
            richTextBox2.Text = yisheng;
            zuihoushuju = "  ";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("诊断", "  筛选", false, "");
            ldo.ShowDialog();
            zhenduan = zuihoushuju;
            if (zhenduan == "" || zhenduan == null) { }
            else { zhenduan = zhenduan.Substring(0, zhenduan.Length - 1); }
            richTextBox3.Text = zhenduan;
            zuihoushuju = "  ";
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("药品", "  筛选", false, "");
            ldo.ShowDialog();
            yaopin = zuihoushuju;
            if (yaopin == "" || yaopin == null) { }
            else { yaopin = yaopin.Substring(0, yaopin.Length - 1); }
            richTextBox4.Text = yaopin;
            zuihoushuju = "  ";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            tabControl2.TabPages.Remove(tabPage9);
            tabControl2.TabPages.Remove(tabPage10);
            string[] str1 = new string[4] { keshi, yaopin, zhenduan, yisheng };
            RichTextBox[] Rb1 = new RichTextBox[6] { richTextBox1, richTextBox2, richTextBox3, richTextBox4, richTextBox5, richTextBox6 };
            CheckBox[] cb1 = new CheckBox[18] { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6, checkBox7, checkBox8, checkBox9, checkBox10, checkBox11, checkBox12, checkBox13, checkBox14, checkBox15, checkBox16, checkBox17, checkBox18 };
            publicclass pub1 = new publicclass();
            pub1.Emptycondition(str1, Rb1, cb1);
        }

        private void tabControl2_Selecting(object sender, TabControlCancelEventArgs e)
        {

        }

        private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {

        }

        private void button13_Click(object sender, EventArgs e)
        {
            //Form keshi = new KeShiZiDian();
            //keshi.ShowDialog();
            Form ldo = new Form2("科室", "  筛选", false, "");
            ldo.ShowDialog();
            keshi = zuihoushuju;
            if (keshi == "" || keshi == null) { }
            else { keshi = keshi.Substring(0, keshi.Length - 1); }
            richTextBox10.Text = keshi;
            zuihoushuju = "  ";
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //注册事件 
            this.MouseWheel += new MouseEventHandler(FormSample_MouseWheel);
            tabControl1.TabPages.Clear();
            evl_dpreturn.Visible = false;
            evl_dpsave.Visible = false;
            button20.Visible = false;
            button21.Visible = false;
            button43.Visible = false;
            button44.Visible = false;
            button34.Visible = false;
            button35.Visible = false;
            button24.Visible = true;
            button25.Visible = true;
            button26.Visible = true;
            button45.Visible = true;
            button46.Visible = true;
            using (SqlConnection sql = new SqlConnection(zifuc))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = "SELECT action_name from sys_sys_func where subsys_code ='" + name1 + "'"; ;
                SqlDataReader dr = one.ExecuteReader();
                while (dr.Read())
                {
                    if (dr[0].ToString() == "1-1")
                    {
                        tabControl1.TabPages.Add(tabPage1);
                    }
                    if (dr[0].ToString() == "1-2")
                    {
                        button24.Visible = true;
                    }
                    if (dr[0].ToString() == "1-3")
                    {
                        button25.Visible = true;
                    }
                    if (dr[0].ToString() == "1-4")
                    {
                        button26.Visible = true;
                    }
                    if (dr[0].ToString() == "1-5")
                    {
                        button45.Visible = true;
                    } 
                    if (dr[0].ToString() == "1-6")
                    {
                        button46.Visible = true;
                    }
                    if (dr[0].ToString() == "2-1")
                    {
                        tabControl1.TabPages.Add(tabPage2);
                    }
                    if (dr[0].ToString() == "2-2")
                    {
                        evl_dpreturn.Visible = true;
                        evl_dpsave.Visible = true;
                    }
                    if (dr[0].ToString() == "3-1")
                    {
                        tabControl1.TabPages.Add(tabPage3);
                    }
                    if (dr[0].ToString() == "3-2")
                    {
                        button20.Visible = true;
                        button21.Visible = true;
                    }
                    if (dr[0].ToString() == "4-1")
                    {
                        tabControl1.TabPages.Add(tabPage4);
                    }
                    if (dr[0].ToString() == "4-2")
                    {
                        button43.Visible = true;
                        button44.Visible = true;
                    }
                    if (dr[0].ToString() == "5-1")
                    {
                        tabControl1.TabPages.Add(tabPage5);
                    }
                    if (dr[0].ToString() == "5-2")
                    {
                        button34.Visible = true;
                    }
                    if (dr[0].ToString() == "6-1")
                    {
                        tabControl1.TabPages.Add(tabPage6);
                    }
                    if (dr[0].ToString() == "6-2")
                    {
                        button35.Visible = true;
                    }
                    if (dr[0].ToString() == "7-1")
                    {
                        tabControl1.TabPages.Add(tabPage7);
                    }
                }
            }
            tabControl1.TabPages.Add(tabPage25);
        }
        
        #region 滚轮控制下拉
        void FormSample_MouseWheel(object sender, MouseEventArgs e)
        {
            //获取光标位置 
            Point mousePoint = new Point(e.X, e.Y);
            //换算成相对本窗体的位置 
            mousePoint.Offset(this.Location.X, this.Location.Y);
            //判断是否在panel内 
            if (panel13.RectangleToScreen(panel13.DisplayRectangle).Contains(mousePoint))
            {
                //滚动 
                panel13.AutoScrollPosition = new Point(0, panel13.VerticalScroll.Value - e.Delta);
            }
        }
        #endregion

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox1, checkBox2);
            if (checkBox1.Checked)
            {
                dateTimePicker8.Enabled = true;
                dateTimePicker7.Enabled = true;
                checkBox3.Enabled = true;
                checkBox4.Enabled = true;
                checkBox5.Enabled = true;
                checkBox6.Enabled = true;
            }
            if (checkBox1.Checked == false && checkBox2.Checked == false)
            {
                dateTimePicker8.Enabled = false;
                dateTimePicker7.Enabled = false;
                checkBox3.Enabled = false;
                checkBox4.Enabled = false;
                checkBox5.Enabled = false;
                checkBox6.Enabled = false;
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox2, checkBox1);
            if (checkBox2.Checked)
            {
                dateTimePicker8.Enabled = false;
                dateTimePicker7.Enabled = false;
                checkBox3.Enabled = false;
                checkBox4.Enabled = false;
                checkBox5.Enabled = false;
                checkBox6.Enabled = false;
            }
        }

        private void checkBox8_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox8, checkBox7);
            publicclass.xuanze(checkBox8, dateTimePicker5, dateTimePicker6, checkBox9, checkBox10, true);
            if (checkBox8.Checked == false && checkBox7.Checked == false)
            {
                dateTimePicker5.Enabled = false;
                dateTimePicker6.Enabled = false;
                checkBox9.Enabled = false;
                checkBox10.Enabled = false;
            }
        }

        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox7, checkBox8);
            publicclass.xuanze(checkBox7, dateTimePicker5, dateTimePicker6, checkBox9, checkBox10, false);
        }

        private void checkBox12_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox12, checkBox11);
            publicclass.xuanze(checkBox12, dateTimePicker3, dateTimePicker4, checkBox13, checkBox14, true);
            if (checkBox12.Checked == false && checkBox11.Checked == false)
            {
                dateTimePicker3.Enabled = false;
                dateTimePicker4.Enabled = false;
                checkBox13.Enabled = false;
                checkBox14.Enabled = false;
            }
        }

        private void checkBox11_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox11, checkBox12);
            publicclass.xuanze(checkBox11, dateTimePicker3, dateTimePicker4, checkBox13, checkBox14, false);
        }

        private void checkBox15_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox15, checkBox16);
            if (checkBox15.Checked)
            {
                dateTimePicker9.Enabled = true;
                dateTimePicker10.Enabled = true;
            }
            if (checkBox15.Checked == false && checkBox16.Checked == false)
            {
                dateTimePicker9.Enabled = false;
                dateTimePicker10.Enabled = false;
            }
        }

        private void checkBox16_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox16, checkBox15);
            if (checkBox16.Checked)
            {
                dateTimePicker9.Enabled = false;
                dateTimePicker10.Enabled = false;
            }
        }

        private void checkBox17_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox17, checkBox18);
            if (checkBox17.Checked)
            {
                dateTimePicker11.Enabled = true;
                dateTimePicker12.Enabled = true;
            }
            if (checkBox17.Checked == false && checkBox18.Checked == false)
            {
                dateTimePicker11.Enabled = false;
                dateTimePicker12.Enabled = false;
            }
        }

        private void checkBox18_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox18, checkBox17);
            if (checkBox18.Checked)
            {
                dateTimePicker11.Enabled = false;
                dateTimePicker12.Enabled = false;
            }
        }

        private void checkBox14_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox14, checkBox13);
        }

        private void checkBox13_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox13, checkBox14);
        }

        private void checkBox9_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox9, checkBox10);
        }

        private void checkBox10_CheckedChanged(object sender, EventArgs e)
        {
            publicclass.panduan(checkBox10, checkBox9);
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox3.Checked)
            {
                checkBox4.Checked = false;
                checkBox5.Checked = false;
                checkBox6.Checked = false;
            }
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox4.Checked || checkBox5.Checked || checkBox6.Checked)
            {
                checkBox3.Checked = false;
            }
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox4.Checked || checkBox5.Checked || checkBox6.Checked)
            {
                checkBox3.Checked = false;
            }
        }

        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox4.Checked || checkBox5.Checked || checkBox6.Checked)
            {
                checkBox3.Checked = false;
            }
        }



        private void richTextBox10_TabStopChanged(object sender, EventArgs e)
        {
            keshi = zuihoushuju;
            keshi = keshi.Substring(0, keshi.Length - 1);
            richTextBox10.Text = keshi;
            zuihoushuju = "  ";
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            if (dateTimePicker1.Value > dateTimePicker2.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "。。。提醒你");
            }
        }

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            if (dateTimePicker1.Value > dateTimePicker2.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "。。。提醒你");
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox1.Text = "";
            keshi = "";
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox2.Text = "";
            yisheng = "";
        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox3.Text = "";
            zhenduan = "";
        }

        private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox4.Text = "";
            yaopin = "";
        }



        private void button11_Click(object sender, EventArgs e)
        {
            //Form zhenduan = new ZhenDuanZiDian();
            //zhenduan.ShowDialog();
            Form ldo = new Form2("诊断", "  筛选", false, "");
            ldo.ShowDialog();
            zhenduan = zuihoushuju;
            if (zhenduan == "" || zhenduan == null) { }
            else { zhenduan = zhenduan.Substring(0, zhenduan.Length - 1); }
            richTextBox8.Text = zhenduan;
            zuihoushuju = "  ";
        }

        private void button12_Click(object sender, EventArgs e)
        {
            //Form yisheng = new YiShengZiDian2();
            //yisheng.ShowDialog();
            Form ldo = new Form2("医生", "  筛选", false, richTextBox10.Text);
            ldo.ShowDialog();
            yisheng = zuihoushuju;
            if (yisheng == "" || yisheng == null) { }
            else { yisheng = yisheng.Substring(0, yisheng.Length - 1); }
            richTextBox9.Text = yisheng;
            zuihoushuju = "  ";
        }

        private void button15_Click(object sender, EventArgs e)
        {
            this.tabControl7.SelectedIndex = 1;
            string cmdtext = "";//
            string strsql = "";
            ///strsql = "select a.inp_no as 住院号,a.patient_name as 患者,a.dept_name as 科室,a.doctor_name as 主管医生,a.start_date as 入院日期,a.end_date as 出院日期 ,a.diagnosis as 入院诊断,a.diagnosis2 as 出院诊断,b.qianming as 药历书写人,b.writetime as 书写时间  from pt_patient_info a,dianziyaoli b where a.inp_no=b.inp_no and case_id like 'Zy%' ";
            // }
            cmdtext = cmdtext + " and a.end_date between " + " '" + dateTimePicker14.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + dateTimePicker13.Value.ToString("yyyy-MM-dd") + "'";//判断时间范围
            if (richTextBox10.Text != "")
            {
                string dept_name = Connect.addyh(Connect.yy(richTextBox10.Text.Trim(), any));
                cmdtext = cmdtext + " and a.dept_name in" + "(" + dept_name + ")";
            }

            if (richTextBox9.Text != "")
            {
                string doctor_name = Connect.addyh(Connect.yy(richTextBox9.Text.Trim(), any));
                cmdtext = cmdtext + " and a.doctor_name in" + "(" + doctor_name + ")";
            }
            if (richTextBox8.Text != "")
            {
                string diagnosis = Connect.addyh(Connect.yy(richTextBox8.Text.Trim(), any));
                cmdtext = cmdtext + " and a.diagnosis in" + "(" + diagnosis + ")";
            }
            if (richTextBox11.Text != "")
            {
                string patient_name = Connect.addyh(Connect.yy(richTextBox11.Text.Trim(), any));
                cmdtext = cmdtext + " and a.patient_name='" + patient_name + "'";
            }
            if (richTextBox7.Text != "")
            {
                string inp_no = Connect.addyh(Connect.yy(richTextBox7.Text.Trim(), any));
                cmdtext = cmdtext + " and a.inp_no='" + inp_no + "'";
            }
            if (radioButton3.Checked)
            {
                strsql = "select distinct a.inp_no as 住院号,a.patient_name as 患者,a.dept_name as 科室,a.doctor_name as 主管医生,a.start_date as 入院日期,a.end_date as 出院日期 ,a.diagnosis as 入院诊断,a.diagnosis2 as 出院诊断, '' ,'' ,a.case_id  from pt_patient_info a,dianziyaoli b where a.case_id like 'Zy%' and a.inp_no not in (select b.inp_no from dianziyaoli b)  ";
                strsql = strsql + cmdtext;
            }
            if (radioButton4.Checked)
            {
                strsql = "select distinct a.inp_no as 住院号,a.patient_name as 患者,a.dept_name as 科室,a.doctor_name as 主管医生,a.start_date as 入院日期,a.end_date as 出院日期 ,a.diagnosis as 入院诊断,a.diagnosis2 as 出院诊断,b.qianming as 药历书写人,b.writetime as 书写时间 ,a.case_id from pt_patient_info a,dianziyaoli b where a.inp_no=b.inp_no and a.case_id like 'Zy%'  ";
                strsql = strsql + cmdtext;
                if (richTextBox12.Text != "")
                {

                    strsql = strsql + " and b.qianming='" + richTextBox12.Text + "'";
                }
                strsql = strsql + " and b.writetime between " + " '" + dateTimePicker16.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + dateTimePicker15.Value.ToString("yyyy-MM-dd") + "'";//判断时间范围

            }

            SqlConnection sql = new SqlConnection(SQL.constr);
            sql.Open();
            SqlDataAdapter dh = new SqlDataAdapter(strsql, SQL.constr);
            DataTable dt = new DataTable();
            dh.Fill(dt);
            dataGridView4.Rows.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dataGridView4.Rows.Add();
                dataGridView4.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString();
                dataGridView4.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString();
                dataGridView4.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString();
                dataGridView4.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString();
                dataGridView4.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString();
                dataGridView4.Rows[i].Cells[5].Value = dt.Rows[i][5].ToString();
                dataGridView4.Rows[i].Cells[6].Value = dt.Rows[i][6].ToString();
                dataGridView4.Rows[i].Cells[7].Value = dt.Rows[i][7].ToString();
                dataGridView4.Rows[i].Cells[8].Value = dt.Rows[i][8].ToString();
                dataGridView4.Rows[i].Cells[9].Value = dt.Rows[i][9].ToString();
                dataGridView4.Rows[i].Cells[10].Value = dt.Rows[i][10].ToString();

            }
            //this.dataGridView4.DataSource = dt.Tables[0].DefaultView;
            sql.Close();
        }
        #region 电子药历
        public static string dianzi1 = "";
        public static string dianzi2 = "";
        public static string dianzi3 = "";
        public static string dianzi4 = "";
        public static string dianzi5 = "";
        public static string dianzi6 = "";
        public static string dianzi7 = "";
        public static string dianzi8 = "";
        public static string dianzi9 = "";
        public static string dianzi10 = "";
        public static string dianzi11 = "";
        public static string dianzi12 = "";
        public static string dianzi13 = "";
        public static string dianzi14 = "";
        public static string dianzi15 = "";
        public static string dianzi16 = "";
        public static string dianzi17 = "";

        private void dataGridView4_DoubleClick(object sender, EventArgs e)
        {
            this.tabControl7.SelectedIndex = 2;
            string myID;
            myID = dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.cc = dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[10].Value.ToString().Trim();
            //MessageBox.Show(myID,"2222");
            string strsql = "select inp_no , patient_name,sex,birth_date,age,body_height,body_weight,idnum,nation,birthplace,workplace,linkplace,linktel,start_date,end_date,dept_name,bed_no,doctor_name,diagnosis,diagnosis2,allergen,nurse_class,pay_class from pt_patient_info  where  inp_no='" + myID + "' and case_id like 'Zy%'";
            SqlConnection conn = new SqlConnection(SQL.constr);
            conn.Open();
            SqlDataAdapter hhh = new SqlDataAdapter(strsql, SQL.constr);
            DataSet dtt = new DataSet();
            hhh.Fill(dtt);
            for (int i = 0; i < dtt.Tables[0].Rows.Count; i++)
            {
                label100.Text = dtt.Tables[0].Rows[i].ItemArray[0].ToString();//住院号
                label129.Text = dtt.Tables[0].Rows[i].ItemArray[1].ToString();//病人名
                label127.Text = dtt.Tables[0].Rows[i].ItemArray[2].ToString();//性别
                label125.Text = dtt.Tables[0].Rows[i].ItemArray[3].ToString();//出生日期
                label123.Text = dtt.Tables[0].Rows[i].ItemArray[4].ToString();//年龄
                label121.Text = dtt.Tables[0].Rows[i].ItemArray[5].ToString();//身高
                label119.Text = dtt.Tables[0].Rows[i].ItemArray[6].ToString();//体重
                label117.Text = dtt.Tables[0].Rows[i].ItemArray[7].ToString();//身份证
                label115.Text = dtt.Tables[0].Rows[i].ItemArray[8].ToString();//民族
                label112.Text = dtt.Tables[0].Rows[i].ItemArray[9].ToString();//籍贯
                label108.Text = dtt.Tables[0].Rows[i].ItemArray[10].ToString();//工作单位
                label113.Text = dtt.Tables[0].Rows[i].ItemArray[11].ToString();//联系地址
                label103.Text = dtt.Tables[0].Rows[i].ItemArray[12].ToString();//联系电话
                label109.Text = dtt.Tables[0].Rows[i].ItemArray[13].ToString();//入院日期
                label110.Text = dtt.Tables[0].Rows[i].ItemArray[14].ToString();//出院日期
                label107.Text = dtt.Tables[0].Rows[i].ItemArray[15].ToString();//科室
                label106.Text = dtt.Tables[0].Rows[i].ItemArray[16].ToString();//床号
                label104.Text = dtt.Tables[0].Rows[i].ItemArray[17].ToString();//医生
                label105.Text = dtt.Tables[0].Rows[i].ItemArray[18].ToString();//入院诊断
                label97.Text = dtt.Tables[0].Rows[i].ItemArray[19].ToString();//出院诊断
                label101.Text = dtt.Tables[0].Rows[i].ItemArray[20].ToString();//过敏历
                label102.Text = dtt.Tables[0].Rows[i].ItemArray[21].ToString();//护理级别
                label98.Text = dtt.Tables[0].Rows[i].ItemArray[22].ToString();//费用类别
            }
            conn.Close();


            string strsql0106;
            strsql0106 = "select distinct b.testno as 申请号, b.sqxmdh as 申请项目代码, b.sqxmmc as 申请项目名称, b.yblx as 样本类型 , b.cytime as 采样时间 from pt_patient_info a ,pt_examination_info b where a.case_id=b.case_id and  inp_no='" + myID + "'";
            // }
            SqlConnection conn7 = new SqlConnection(SQL.constr);
            conn7.Open();
            SqlDataAdapter dh = new SqlDataAdapter(strsql0106, SQL.constr);
            DataTable dt7 = new DataTable();
            dh.Fill(dt7);
            dataGridView5.Rows.Clear();
            dataGridView5.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;//这句代码，可以将datagridvies的行的高度变小
            for (int i = 0; i < dt7.Rows.Count; i++)
            {
                dataGridView5.Rows.Add();
                dataGridView5.Rows[i].Cells[0].Value = dt7.Rows[i][0].ToString();
                dataGridView5.Rows[i].Cells[1].Value = dt7.Rows[i][1].ToString();
                dataGridView5.Rows[i].Cells[2].Value = dt7.Rows[i][2].ToString();
                dataGridView5.Rows[i].Cells[3].Value = dt7.Rows[i][3].ToString();
                dataGridView5.Rows[i].Cells[4].Value = dt7.Rows[i][4].ToString();

            }
            //this.dataGridView13.DataSource = dt1.Tables[0].DefaultView;
            conn7.Close();



            string strsql10001;
            strsql10001 = "select case when b.order_class=1 then '临'  when b.order_class=3 then '长'  end as 长临,b.order_text ,b.drug_form , b.drug_spec  ,b.route_name ,  b.dose , b.dose_units ,b.num  ,b.num_units ,b.start_date_time ,b.end_date_time ,b.skintestresult , b.doctor_name ,b.dept_name from pt_patient_info a ,pt_orders b where a.case_id=b.case_id and  inp_no='" + myID + "'";
            SqlConnection conn2 = new SqlConnection(SQL.constr);
            conn2.Open();
            SqlDataAdapter dh1 = new SqlDataAdapter(strsql10001, SQL.constr);
            DataTable dt2 = new DataTable();
            dh1.Fill(dt2);
            dataGridView6.Rows.Clear();
            dataGridView6.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;//这句代码，可以将datagridvies的行的高度变小
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                dataGridView6.Rows.Add();
                dataGridView6.Rows[i].Cells[1].Value = dt2.Rows[i][0].ToString();//长临
                dataGridView6.Rows[i].Cells[6].Value = dt2.Rows[i][1].ToString();//药品名称
                dataGridView6.Rows[i].Cells[7].Value = dt2.Rows[i][2].ToString();//剂型
                dataGridView6.Rows[i].Cells[8].Value = dt2.Rows[i][3].ToString();//规格
                dataGridView6.Rows[i].Cells[9].Value = dt2.Rows[i][4].ToString();
                dataGridView6.Rows[i].Cells[10].Value = dt2.Rows[i][5].ToString();
                dataGridView6.Rows[i].Cells[11].Value = dt2.Rows[i][6].ToString();
                dataGridView6.Rows[i].Cells[12].Value = dt2.Rows[i][7].ToString();
                dataGridView6.Rows[i].Cells[13].Value = dt2.Rows[i][8].ToString();
                dataGridView6.Rows[i].Cells[14].Value = dt2.Rows[i][9].ToString();//开嘱时间
                dataGridView6.Rows[i].Cells[15].Value = dt2.Rows[i][10].ToString();//停嘱时间
                dataGridView6.Rows[i].Cells[17].Value = dt2.Rows[i][11].ToString();//皮试结果
                dataGridView6.Rows[i].Cells[18].Value = dt2.Rows[i][12].ToString();//开嘱医生
                dataGridView6.Rows[i].Cells[19].Value = dt2.Rows[i][13].ToString();//科室

            }
            conn2.Close();


            //新增加调查表空间
            string sqllll0 = "select * from dianziyaoli  where inp_no='" + dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[0].Value.ToString() + "' ";
            SqlConnection conn55660 = new SqlConnection(SQL.constr);
            conn55660.Open();
            SqlDataAdapter da90 = new SqlDataAdapter(sqllll0, conn55660);
            DataTable dt09 = new DataTable();
            da90.Fill(dt09);
            if (dt09.Rows.Count > 0)
            {

                button33.Enabled = false;
            }
            else
            {


                button33.Enabled = true;
            }
            conn55660.Close();


            dianzi1 = label100.Text;
            dianzi2 = label129.Text;
            dianzi3 = label127.Text;
            dianzi4 = label125.Text;
            dianzi5 = label109.Text;
            dianzi6 = label110.Text;
            dianzi7 = label121.Text;
            dianzi8 = label119.Text;
            dianzi9 = label112.Text;
            dianzi10 = label115.Text;
            dianzi11 = label107.Text;
            dianzi12 = label104.Text;
            dianzi13 = label106.Text;
            dianzi14 = label108.Text;
            dianzi15 = label113.Text;
            dianzi16 = label105.Text;
            dianzi17 = label97.Text;

        }


        #endregion



        //zhaoming  2012-05-20
        DataTable biao = new DataTable();
        string sqlyuj1, sqlyuj2;
        string zifuc = @"server=.;database=PASS;Integrated Security=True";
        private void button6_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            RichTextBox[] Rb1 = new RichTextBox[6] { richTextBox1, richTextBox2, richTextBox3, richTextBox4, richTextBox5, richTextBox6 };
            CheckBox[] cb1 = new CheckBox[18] { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6, checkBox7, checkBox8, checkBox9, checkBox10, checkBox11, checkBox12, checkBox13, checkBox14, checkBox15, checkBox16, checkBox17, checkBox18 };
            DateTimePicker[] dtp1 = new DateTimePicker[12] { dateTimePicker1, dateTimePicker2, dateTimePicker3, dateTimePicker4, dateTimePicker5, dateTimePicker6, dateTimePicker7, dateTimePicker8, dateTimePicker9, dateTimePicker10, dateTimePicker11, dateTimePicker12 };
            RadioButton[] rb1 = new RadioButton[2] { radioButton1, radioButton2 };
            LinkLabel[] ll1 = new LinkLabel[6] { linkLabel1, linkLabel2, linkLabel3, linkLabel4, linkLabel5, linkLabel6 };
            chufangchaxufp cfcx1 = new chufangchaxufp();
            sqlyuj1 = "select DISTINCT a.case_id AS 编号,a.inp_no as 门诊号, a.patient_name AS 患者, a.dept_name AS 科室, a.doctor_name AS 医生, a.start_date AS 就诊日期, a.diagnosis AS 临床诊断,case a.cf_level when '1' then '不规范处方' when '2' then '用药不适宜处方'  when '3' then '超常处方' when '0' then '合理' end AS 处方点评, a.type AS 手术, a.cost AS 总费用, a.drugcost AS 药品金额 from chaxubiao a ";
            if (richTextBox4.Text.Trim() != "")
            {
                sqlyuj1 += "left JOIN pt_orders b ON a.case_id =b.case_id ";
            }
            sqlyuj2 = cfcx1.Querycondition(sqlyuj2, Rb1, dtp1, rb1, ll1, cb1);
            biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
            int[] trinr = new int[11] { 80, 110, 110, 130, 110, 120, 220, 40, 110, 70, 70 };
            for (int kkk = 0; kkk < biao.Columns.Count; kkk++)
            {
                dataGridView1.Columns.Add(new DataGridViewTextBoxColumn());
                dataGridView1.Columns[kkk].Width = trinr[kkk];
                dataGridView1.Columns[kkk].HeaderText = biao.Columns[kkk].ColumnName;
                dataGridView1.Columns[kkk].DataPropertyName = biao.Columns[kkk].ToString();
            }
            this.dataGridView1.DataSource = biao;
            this.dataGridView1.Columns[0].Visible = false;
            //判断tabpage是否在tabpages集合中，如不在，新增。
            publicclass th = new publicclass();
            th.tabpageadd(tabControl2, tabPage9);
            //清空中间数据
            keshi = "";
            yaopin = "";
            zhenduan = "";
            yisheng = "";
            any.Clear();
            bny.Clear();
            eny.Clear();
        }//zhaoming


        private void dataGridView5_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DangQianHang.aa = dataGridView5.Rows[dataGridView5.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = dataGridView5.Rows[dataGridView5.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            jianyanxiagnxi.ShowDialog();
        }


        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        #region 抗菌药物临床应用调查查询结果
        private void button28_Click(object sender, EventArgs e)
        {
            string cmdText = "";
            string strsql010 = "";
            if (comboBox1.Text == "")
            { cmdText = cmdText + " and a.case_id not in (select case_id from dbo.pt_operation_info )  "; }
            if (comboBox1.Text == "非手术病人抗菌药物临床应用调查表")
            { cmdText = cmdText + " and a.case_id not in (select case_id from dbo.pt_operation_info )  "; }
            else if (comboBox1.Text == "甲状腺手术病人抗菌药物临床应用调查表")
            { cmdText = cmdText + " and a.case_id in (select case_id from dbo.pt_operation_info where type=1 ) "; }
            else if (comboBox1.Text == "乳房手术病人抗菌药物应用调查")
            { cmdText = cmdText + " and a.case_id in (select case_id from dbo.pt_operation_info where type=2)  "; }
            else if (comboBox1.Text == "腹外疝手术病人抗菌药物应用调查表")
            { cmdText = cmdText + " and a.case_id in (select case_id from dbo.pt_operation_info where type=3)  "; }
            else if (comboBox1.Text == "手术病人抗菌药物临床应用调查表")
            { cmdText = cmdText + " and a.case_id in (select case_id from dbo.pt_operation_info )  "; }
            cmdText = cmdText + " and a.start_date between " + " '" + dateTimePicker18.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + dateTimePicker17.Value.ToString("yyyy-MM-dd") + "'";//判断时间范围
            if (textBox7.Text != "")
            { cmdText = cmdText + " and a.inp_no='" + textBox7.Text + "'"; }


            if (radioButton13.Checked)//查询未填调查表的
            {

                strsql010 = "select distinct a.inp_no ,a.patient_name ,a.dept_name ,a.start_date ,a.end_date ,a.diagnosis ,a.diagnosis2 ,'', a.case_id from pt_patient_info a    where left(a.case_id,2)='Zy'  and a.inp_no not in (select b.inp_no from diaochabiao_1 b)";
                strsql010 = strsql010 + cmdText;
            }
            if (radioButton14.Checked)//已填调查表的
            {

                strsql010 = "select distinct a.inp_no ,a.patient_name ,a.dept_name ,a.start_date ,a.end_date ,a.diagnosis ,a.diagnosis2 ,b.tianbiao,a.case_id from pt_patient_info a ,diaochabiao_1 b   where left(a.case_id,2)='Zy'  and  a.inp_no=b.inp_no";
                strsql010 = strsql010 + cmdText;

            }

            SqlConnection conn1 = new SqlConnection(SQL.constr);
            conn1.Open();
            SqlDataAdapter dh = new SqlDataAdapter(strsql010, SQL.constr);
            DataTable dt1 = new DataTable();
            dh.Fill(dt1);
            dataGridView11.Rows.Clear();
            for (int i = 0; i < dt1.Rows.Count; i++)
            {

                dataGridView11.Rows.Add();
                dataGridView11.Rows[i].Cells[0].Value = dt1.Rows[i][0].ToString();
                dataGridView11.Rows[i].Cells[1].Value = dt1.Rows[i][1].ToString();
                dataGridView11.Rows[i].Cells[2].Value = dt1.Rows[i][2].ToString();
                //dataGridView11.Rows[i].Cells[3].Value = dt1.Rows[i][3].ToString();
                dataGridView11.Rows[i].Cells[3].Value = dt1.Rows[i][3].ToString();
                dataGridView11.Rows[i].Cells[4].Value = dt1.Rows[i][4].ToString();
                dataGridView11.Rows[i].Cells[5].Value = dt1.Rows[i][5].ToString();
                dataGridView11.Rows[i].Cells[6].Value = dt1.Rows[i][6].ToString();
                dataGridView11.Rows[i].Cells[7].Value = dt1.Rows[i][7].ToString();
                dataGridView11.Rows[i].Cells[8].Value = dt1.Rows[i][8].ToString();
            }
            //this.dataGridView11.DataSource = dt1.Tables[0].DefaultView;
            conn1.Close();
        }
        #endregion

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            int i = dataGridView1.CurrentRow.Index;
            xh = i;
            string row1 = dataGridView1.Rows[i].Cells[0].Value.ToString();
                //获得当前选中的记录的住院号
            for (int t = 0; t < dataGridView1.Rows.Count-1; t++)
            {
                eny.Add(dataGridView1.Rows[t].Cells[0].Value.ToString());
            }
            NewMethod(row1);
        }
        private void NewMethod(string row1)
        {
            
            biao = new DataTable();
            string sqlyuj1, sqlyuj2;
            

            Label[] labe = new Label[22] { label60, label61, label62, label63, label64, label65, label66, label67, label68, label70, label71, label72, label73, label74, label75, label76, label77, label78, label79, label80, label81, label82 };
            //根据住院号将病人的基本信息检索出来，写进标签中
            using (SqlConnection sql = new SqlConnection(SQL.constr))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = "SELECT inp_no, patient_name, sex, birth_date, age, body_height, body_weight, idnum, nation, workplace, linkplace, linktel, start_date, end_date, dept_name, bed_no, doctor_name, diagnosis, diagnosis2, allergen, nurse_class, pay_class FROM pt_patient_info where case_id ='" + row1 + "'";
                SqlDataReader dr = one.ExecuteReader();
                dr.Read();
                if (dr != null)
                {
                    for (int j = 0; j < 22; j++)
                    {
                        labe[j].Text = dr[j].ToString();
                    }
                }
                sql.Close();
            }
                sqlyuj1 = "exec [Get_operation_info]";
                sqlyuj2 = row1;
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                if (biao.Rows.Count == 0)
                {
                    panel50.Visible = false;
                }
                else
                {
                    panel50.Visible = true;

                }
                dataGridView19.DataSource = biao;
                publicclass t1 = new publicclass();
                sqlyuj1 = "exec [Get_exam_main]";
                sqlyuj2 = row1;
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                if (biao.Rows.Count == 0)
                {
                    panel3.Visible = false;
                }
                else
                {
                    panel3.Visible = true;
                    
                    for (int kkk = 0; kkk < biao.Columns.Count; kkk++)
                    {
                        dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
                        dataGridView2.Columns[kkk].Width = 226;
                        dataGridView2.Columns[kkk].HeaderText = biao.Columns[kkk].ColumnName;
                        dataGridView2.Columns[kkk].DataPropertyName = biao.Columns[kkk].ToString();
                    }
                    dataGridView2.DataSource = biao;
                }
                
                
                //根据住院号将病人的医嘱信息检索出来，写进datagridview中
                sqlyuj1 = "exec[Get_pt_orders]";
                sqlyuj2 = "'" + row1 + "','" + row1.Remove(2) + "'";
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                if (biao.Rows.Count != 0)
                {
                    panel4.Visible = true;
                    
                } int[] kim = new int[19] { 20, 40, 20, 20, 20, 20, 100, 60, 100, 60, 50, 80, 80, 80, 80, 80, 80, 80,80 };
                for (int kkk = 0; kkk < biao.Columns.Count; kkk++)
                {
                    dataGridView3.Columns.Add(new DataGridViewTextBoxColumn());
                    dataGridView3.Columns[kkk].Width = kim[kkk];
                    dataGridView3.Columns[kkk].HeaderText = biao.Columns[kkk].ColumnName;
                    dataGridView3.Columns[kkk].DataPropertyName = biao.Columns[kkk].ToString();
                }
                dataGridView3.DataSource = biao.DefaultView;
                //判断点评信息是否完成
                sqlyuj1 = "select isnull(cf_level,''),isnull(wsq_level,''),isnull(zl_level,''),isnull(tianbiao,''),isnull(writer,'') from chaxubiao ";
                sqlyuj2 = " where case_id ='" + row1 + "'";
                using (SqlConnection sql = new SqlConnection(SQL.constr))
                {
                    Button[] button = new Button[5] { button24, button25, button26, button45, button46 };
                    sql.Open();
                    SqlCommand one = sql.CreateCommand();
                    one.CommandText = sqlyuj1 + sqlyuj2;
                    SqlDataReader dr = one.ExecuteReader();
                    dr.Read();
                    for (int i = 0; i < 5; i++)
                    {
                        if (dr[i].ToString() == "")
                        {
                            button[i].Visible = false;
                        }
                    }
                }
                //判断tabpage是否已存在，如不存在，新添加进去
                publicclass pub1 = new publicclass();
                pub1.tabpageadd(tabControl2, tabPage10);
            
        }
        public static int num=5;
        #region 抗菌药物临床应用调查显示医嘱明细
        public static string xb = "";
        public static string nl = "";
        public static string tz = "";
        public static string rysj = "";
        public static string cysj = "";
        public static string shmc = "";
        public static string qklx = "";
        public static string rysj1 = "";
        public static string cysj1 = "";
        public static string blh = "";
        public static string cyzd = "";//出院诊断
        public static string ssks01 = "";//病人所属科室
        //获得遗嘱信息方法
        public void get_yizhu1()
        {
            string case_idi;
            case_idi = dataGridView11.Rows[dataGridView11.CurrentRow.Index].Cells[8].Value.ToString().Trim();
            DangQianHang.cc = case_idi;
            string strsql10001;
            strsql10001 = "exec [Get_pt_orders]'" + case_idi + "','Zy'";
            SqlConnection conn2 = new SqlConnection(SQL.constr);
            conn2.Open();
            SqlDataAdapter dh1 = new SqlDataAdapter(strsql10001, SQL.constr);
            DataTable dt2 = new DataTable();
            dh1.Fill(dt2);
            dataGridView12.Rows.Clear();
            dataGridView12.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;//这句代码，可以将datagridvies的行的高度变小
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                dataGridView12.Rows.Add();
                dataGridView12.Rows[i].Cells[0].Value = dt2.Rows[i][0].ToString();//组
                dataGridView12.Rows[i].Cells[1].Value = dt2.Rows[i][1].ToString();//长临
                dataGridView12.Rows[i].Cells[2].Value = dt2.Rows[i][2].ToString();//基
                dataGridView12.Rows[i].Cells[3].Value = dt2.Rows[i][3].ToString();//抗
                dataGridView12.Rows[i].Cells[4].Value = dt2.Rows[i][4].ToString();//兴
                dataGridView12.Rows[i].Cells[5].Value = dt2.Rows[i][5].ToString();//特
                dataGridView12.Rows[i].Cells[6].Value = dt2.Rows[i][6].ToString();//药品
                dataGridView12.Rows[i].Cells[7].Value = dt2.Rows[i][7].ToString();//剂型
                dataGridView12.Rows[i].Cells[8].Value = dt2.Rows[i][8].ToString();//规格
                dataGridView12.Rows[i].Cells[9].Value = dt2.Rows[i][9].ToString();//给药途径
                dataGridView12.Rows[i].Cells[10].Value = dt2.Rows[i][10].ToString();//量次
                dataGridView12.Rows[i].Cells[11].Value = dt2.Rows[i][11].ToString();//给药单位
                //dataGridView12.Rows[i].Cells[12].Value = dt2.Rows[i][12].ToString();//
                //dataGridView12.Rows[i].Cells[13].Value = dt2.Rows[i][13].ToString();//
                dataGridView12.Rows[i].Cells[14].Value = dt2.Rows[i][12].ToString();//开嘱时间
                dataGridView12.Rows[i].Cells[15].Value = dt2.Rows[i][13].ToString();//停嘱时间
                dataGridView12.Rows[i].Cells[16].Value = dt2.Rows[i][14].ToString();//目的
                dataGridView12.Rows[i].Cells[17].Value = dt2.Rows[i][15].ToString();//皮实结果
                dataGridView12.Rows[i].Cells[18].Value = dt2.Rows[i][16].ToString();//开嘱医生
                dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][17].ToString();//执行科室
                //dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][14].ToString();//

            }
            //this.dataGridView11.DataSource = dt1.Tables[0].DefaultView;
            conn2.Close();
        }
        private void dataGridView11_DoubleClick(object sender, EventArgs e)
        {

            this.tabControl6.SelectedIndex = 1;
            string myID;
            myID = dataGridView11.Rows[dataGridView11.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列

            //MessageBox.Show(myID,"2222");
            string strsql = "select inp_no , patient_name,sex,birth_date,age,body_height,body_weight,idnum,nation,birthplace,workplace,linkplace,linktel,start_date,end_date,dept_name,bed_no,doctor_name,diagnosis,diagnosis2,allergen,nurse_class,pay_class from pt_patient_info  where  inp_no='" + myID + "' and case_id like 'Zy%'";
            SqlConnection conn = new SqlConnection(SQL.constr);
            conn.Open();
            SqlDataAdapter hhh = new SqlDataAdapter(strsql, SQL.constr);
            DataSet dtt = new DataSet();
            hhh.Fill(dtt);
            for (int i = 0; i < dtt.Tables[0].Rows.Count; i++)
            {
                label246.Text = dtt.Tables[0].Rows[i].ItemArray[0].ToString();//住院号
                label275.Text = dtt.Tables[0].Rows[i].ItemArray[1].ToString();//病人名
                label273.Text = dtt.Tables[0].Rows[i].ItemArray[2].ToString();//性别
                label271.Text = dtt.Tables[0].Rows[i].ItemArray[3].ToString();//出生日期
                label269.Text = dtt.Tables[0].Rows[i].ItemArray[4].ToString();//年龄
                label267.Text = dtt.Tables[0].Rows[i].ItemArray[5].ToString();//身高
                label265.Text = dtt.Tables[0].Rows[i].ItemArray[6].ToString();//体重
                label263.Text = dtt.Tables[0].Rows[i].ItemArray[7].ToString();//身份证
                label261.Text = dtt.Tables[0].Rows[i].ItemArray[8].ToString();//民族
                label258.Text = dtt.Tables[0].Rows[i].ItemArray[9].ToString();//籍贯
                label254.Text = dtt.Tables[0].Rows[i].ItemArray[10].ToString();//工作单位
                label259.Text = dtt.Tables[0].Rows[i].ItemArray[11].ToString();//联系地址
                label249.Text = dtt.Tables[0].Rows[i].ItemArray[12].ToString();//联系电话
                label255.Text = dtt.Tables[0].Rows[i].ItemArray[13].ToString();//入院日期
                label256.Text = dtt.Tables[0].Rows[i].ItemArray[14].ToString();//出院日期
                label253.Text = dtt.Tables[0].Rows[i].ItemArray[15].ToString();//科室
                label252.Text = dtt.Tables[0].Rows[i].ItemArray[16].ToString();//床号
                label250.Text = dtt.Tables[0].Rows[i].ItemArray[17].ToString();//医生
                label251.Text = dtt.Tables[0].Rows[i].ItemArray[18].ToString();//入院诊断
                label243.Text = dtt.Tables[0].Rows[i].ItemArray[19].ToString();//出院诊断
                label247.Text = dtt.Tables[0].Rows[i].ItemArray[20].ToString();//过敏历
                label248.Text = dtt.Tables[0].Rows[i].ItemArray[21].ToString();//护理级别
                label244.Text = dtt.Tables[0].Rows[i].ItemArray[22].ToString();//费用类别
            }
            conn.Close();

            //获得遗嘱
            get_yizhu1();
            

            //遗嘱详细

            string strsql010;
            strsql010 = "select distinct b.testno as 申请号, b.sqxmdh as 申请项目代码, b.sqxmmc as 申请项目名称, b.yblx as 样本类型 , b.cytime as 采样时间 from pt_patient_info a ,pt_examination_info b where a.case_id=b.case_id and  inp_no='" + myID + "'";
            // }
            SqlConnection conn1 = new SqlConnection(SQL.constr);
            conn1.Open();
            SqlDataAdapter dh = new SqlDataAdapter(strsql010, SQL.constr);
            DataTable dt4 = new DataTable();
            dh.Fill(dt4);
            dataGridView13.Rows.Clear();
            dataGridView13.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;//这句代码，可以将datagridvies的行的高度变小
            for (int i = 0; i < dt4.Rows.Count; i++)
            {
                dataGridView13.Rows.Add();
                dataGridView13.Rows[i].Cells[0].Value = dt4.Rows[i][0].ToString();
                dataGridView13.Rows[i].Cells[1].Value = dt4.Rows[i][1].ToString();
                dataGridView13.Rows[i].Cells[2].Value = dt4.Rows[i][2].ToString();
                dataGridView13.Rows[i].Cells[3].Value = dt4.Rows[i][3].ToString();
                dataGridView13.Rows[i].Cells[4].Value = dt4.Rows[i][4].ToString();

            }
            //this.dataGridView13.DataSource = dt1.Tables[0].DefaultView;
            conn1.Close();


            string strsql110;
            //strsql110 = "select  a.peration_name , a.start_date , a.end_date , b.type, a.shuqian_time ,a.shuzhong,a.shuhou from pt_operation_info a ,pt_opr_incision_info b where a.case_id=b.case_id and  a.case_id=(select case_id from pt_patient_info where inp_no='" + myID + "')";
            strsql110 = "select distinct  a.peration_name , a.start_date , a.end_date , b.type, a.shuqian_time ,a.shuzhong,a.shuhou from pt_operation_info a ,pt_opr_incision_info b where a.case_id=b.case_id and  a.case_id in (select case_id from pt_patient_info where inp_no='" + myID + "')";
            SqlConnection conn110 = new SqlConnection(SQL.constr);
            conn110.Open();
            SqlDataAdapter dh110 = new SqlDataAdapter(strsql110, SQL.constr);
            DataTable dt110 = new DataTable();
            dh110.Fill(dt110);
            dataGridView14.Rows.Clear();
            dataGridView14.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;//这句代码，可以将datagridvies的行的高度变小
            if (comboBox1.Text == "非手术病人抗菌药物临床应用调查表")
            {
                dataGridView14.Rows.Add();
                dataGridView14.Rows[0].Cells[0].Value = "无";
                dataGridView14.Rows[0].Cells[1].Value = "无";
                dataGridView14.Rows[0].Cells[2].Value = "无";
                dataGridView14.Rows[0].Cells[3].Value = "无";
                dataGridView14.Rows[0].Cells[4].Value = "无";
                dataGridView14.Rows[0].Cells[5].Value = "无";
                dataGridView14.Rows[0].Cells[6].Value = "无";
            }
            else if (comboBox1.Text == "")
            {
                dataGridView14.Rows.Add();
                dataGridView14.Rows[0].Cells[0].Value = "无";
                dataGridView14.Rows[0].Cells[1].Value = "无";
                dataGridView14.Rows[0].Cells[2].Value = "无";
                dataGridView14.Rows[0].Cells[3].Value = "无";
                dataGridView14.Rows[0].Cells[4].Value = "无";
                dataGridView14.Rows[0].Cells[5].Value = "无";
                dataGridView14.Rows[0].Cells[6].Value = "无";
            }
            else
            {
                for (int i = 0; i < dt110.Rows.Count; i++)
                {
                    dataGridView14.Rows.Add();
                    dataGridView14.Rows[i].Cells[0].Value = dt110.Rows[i][0].ToString();
                    dataGridView14.Rows[i].Cells[1].Value = dt110.Rows[i][1].ToString();
                    dataGridView14.Rows[i].Cells[2].Value = dt110.Rows[i][2].ToString();
                    dataGridView14.Rows[i].Cells[3].Value = dt110.Rows[i][3].ToString();
                    dataGridView14.Rows[i].Cells[4].Value = dt110.Rows[i][4].ToString();
                    dataGridView14.Rows[i].Cells[5].Value = dt110.Rows[i][5].ToString();
                    dataGridView14.Rows[i].Cells[6].Value = dt110.Rows[i][6].ToString();

                }
            }
            conn110.Close();


            //新增加调查表空间

            string sqllll = "select * from table_ak a  , diaochabiao_1 b  where a.inp_no=b.inp_no  and b.inp_no='" + dataGridView11.Rows[dataGridView11.CurrentRow.Index].Cells[0].Value.ToString() + "' ";
            SqlConnection conn5566 = new SqlConnection(SQL.constr);
            conn5566.Open();
            SqlDataAdapter da = new SqlDataAdapter(sqllll, conn5566);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {

                button32.Enabled = false;
            }
            else
            {


                button32.Enabled = true;
            }
            conn5566.Close();





        }

        #endregion


        //evl为处方（医嘱）点评模块代码，by tanqianyun 


        #region 选择抽样条件/查看点评结果
        private void evl_cytj_CheckedChanged(object sender, EventArgs e)
        {
            if (evl_cytj.Checked == true)
            {
                evl_panel2.Enabled = false;
                evl_panel1.Enabled = true;
            }
            else
            {
                evl_panel1.Enabled = false;
                evl_panel2.Enabled = true;
            }

        }

        private void evl_ckdpjg_CheckedChanged(object sender, EventArgs e)
        {
            if (evl_ckdpjg.Checked == true)
            {
                evl_panel1.Enabled = false;
                evl_panel2.Enabled = true;
            }
            else
            {
                evl_panel2.Enabled = false;
                evl_panel1.Enabled = true;
            }
        }

        //当开始时间大于结束时间时，提醒用户
        private void evlbegindt1_ValueChanged(object sender, EventArgs e)
        {
            if (evlbegindt1.Value > evlenddt1.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "注意O(∩_∩)O~");
            }
        }

        private void evlenddt1_ValueChanged(object sender, EventArgs e)
        {
            if (evlbegindt1.Value > evlenddt1.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "注意O(∩_∩)O~");
            }
        }

        private void evlbegindt2_ValueChanged(object sender, EventArgs e)
        {
            if (evlbegindt2.Value > evlenddt2.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "注意O(∩_∩)O~");
            }
        }

        private void evlenddt2_ValueChanged(object sender, EventArgs e)
        {
            if (evlbegindt2.Value > evlenddt2.Value)
            {
                MessageBox.Show("开始时间大于结束时间，请改正", "注意O(∩_∩)O~");
            }
        }

        //选择病人科室
        private void evldeptchoice_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("科室", "筛选", evltype1_1.Checked, "");
            ldo.ShowDialog();
            evldeptlist_TabStopChanged(sender, e);
        }

        private void evldeptlist_TabStopChanged(object sender, EventArgs e)
        {
            keshi = zuihoushuju;
            if (keshi == "" || keshi == null) { }
            else { keshi = keshi.Substring(0, keshi.Length - 1); }
            evldeptlist.Text = keshi;
            zuihoushuju = "  ";
        }
        //清空病人科室
        private void evldeptclear_Click(object sender, EventArgs e)
        {
            evldeptlist.Text = "";
            keshi = "";
        }
        //选择开嘱医生
        private void evldoctorchoice_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("医生", "筛选", false, evldeptlist.Text);
            ldo.ShowDialog();
            evldoctorlist_TabStopChanged(sender, e);
        }

        private void evldoctorlist_TabStopChanged(object sender, EventArgs e)
        {
            yisheng = zuihoushuju;
            if (yisheng == "" || yisheng == null) { }
            else { yisheng = yisheng.Substring(0, yisheng.Length - 1); }
            evldoctorlist.Text = yisheng;
            zuihoushuju = "  ";
        }
        //清空开嘱医生
        private void evldoctorclear_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            evldoctorlist.Text = "";
            yisheng = "";
        }
        //选择诊断
        private void evlicdchoice_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("诊断", "筛选", false, "");
            ldo.ShowDialog();
            evlicdlist_TabStopChanged(sender, e);
        }

        private void evlicdlist_TabStopChanged(object sender, EventArgs e)
        {
            zhenduan = zuihoushuju;
            if (zhenduan == "" || zhenduan == null) { }
            else { zhenduan = zhenduan.Substring(0, zhenduan.Length - 1); }
            evlicdlist.Text = zhenduan;
            zuihoushuju = "  ";
        }
        //清空诊断
        private void evlicdclear_Click(object sender, EventArgs e)
        {
            evlicdlist.Text = "";
            zhenduan = "";
        }
        //选择药品
        private void evldrugchoice_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("药品", "筛选", false, "");
            ldo.ShowDialog();
            evldruglist_TabStopChanged(sender, e);
        }

        private void evldruglist_TabStopChanged(object sender, EventArgs e)
        {
            yaopin = zuihoushuju;
            if (yaopin == "" || yaopin == null) { }
            else { yaopin = yaopin.Substring(0, yaopin.Length - 1); }
            evldruglist.Text = yaopin;
            zuihoushuju = "  ";
        }
        //清空药品
        private void evldrugclear_Click(object sender, EventArgs e)
        {
            evldruglist.Text = "";
            yaopin = "";
        }
        //选择点评人
        private void evlcommentchoice_Click(object sender, EventArgs e)
        {
            Form choseuser = new dian_ping_ren();
            choseuser.ShowDialog();
            if (yonghu != "")
            {
                yonghu = yonghu.Remove(yonghu.LastIndexOf(","), 1);
            }
            evlcommentname.Text = yonghu;
            yonghu = "";
        }

        //清除所有条件功能
        private void evlclearall_Click(object sender, EventArgs e)
        {
            evldeptlist.Text = "";
            keshi = "";
            evldoctorlist.Text = "";
            yisheng = "";
            evlicdlist.Text = "";
            zhenduan = "";
            evldruglist.Text = "";
            yaopin = "";
            evlpnamelist.Text = "";
            evlpidlist.Text = "";
            evlsearchcount.Text = "";
            evl_hl.Checked = false;
            evl_bgf.Checked = false;
            evl_bsy.Checked = false;
            evl_cccf.Checked = false;
            evlcommentname.Text = "";
        }

        #endregion

        #region 立即执行查询功能
        private void evlbeginsearch_Click(object sender, EventArgs e)
        {
            //选择抽样条件
            if (evl_cytj.Checked)
            {
                chose1 = true;
                chose2 = false;
                if (evltype1_1.Checked)//选择门（急）诊
                {
                    mztype = true;
                    zytype = false;
                    publicclass th = new publicclass();
                    th.tabpageadd(tabControl3, tabPage12);
                    this.tabControl3.SelectedIndex = 1;
                    string cmdText;
                    cmdText = " case_id as 编码,isnull(inp_no,'') as 门诊号,isnull(patient_name,'') as 患者,isnull(dept_name,'') as 科室,isnull(doctor_name,'') as 看诊医生,isnull(start_date,'') as 入院日期,isnull(end_date,'') as 出院日期,isnull(diagnosis,'') as 入院诊断,isnull(diagnosis2,'') as 出院诊断,'' as 点评结果,'' as 点评时间,'' as 点评人 from dbo.pt_patient_info ";
                    if (richTextBox15.Text != "")
                    {
                        if (radioButton19.Checked)
                        {
                            cmdText = cmdText + " TABLESAMPLE SYSTEM (" + richTextBox15.Text + " PERCENT)";
                        }
                        else if (radioButton20.Checked)
                        {
                            cmdText = cmdText + " TABLESAMPLE SYSTEM (" + richTextBox15.Text + "*0.1 PERCENT)";
                        }
                    }
                    cmdText = cmdText + " where left(case_id,2)='Mz' and case_id not in (select case_id from evaluate_main)";
                    if (evlsearchcount.Text != "")
                    {
                        cmdText = "select top " + evlsearchcount.Text + cmdText;
                    }
                    else
                    {
                        cmdText = "select " + cmdText;
                    }
                    cmdText = cmdText + " and start_date between " + " '" + evlbegindt1.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + evlenddt1.Value.ToString("yyyy-MM-dd") + "'";
                    if (evldeptlist.Text != "")
                    {
                        string dept_name = Connect.addyh(Connect.yy(evldeptlist.Text.Trim(), any));
                        cmdText = cmdText + " and dept_name in" + "(" + dept_name + ")";
                    }
                    if (evldoctorlist.Text != "")
                    {
                        string doctor_name = Connect.addyh(Connect.yy(evldoctorlist.Text.Trim(), any));
                        cmdText = cmdText + " and doctor_name in" + "(" + doctor_name + ")";
                    }
                    if (evlicdlist.Text != "")
                    {
                        string diagnosis = Connect.addyh(Connect.yy(evlicdlist.Text.Trim(), any));
                        cmdText = cmdText + " and diagnosis in" + "(" + diagnosis + ")";
                    }
                    if (evldruglist.Text != "")
                    {
                        cmdText = cmdText + " and case_id in (select case_id from dbo.pt_orders where order_text in (" + evldruglist.Text + ")";
                    }
                    if (evlpnamelist.Text != "")
                    {
                        string patient_name = Connect.addyh(Connect.yy(evlpnamelist.Text.Trim(), any));
                        cmdText = cmdText + " and patient_name in " + "(" + patient_name + ")";
                    }
                    if (evlpidlist.Text != "")
                    {
                        string inp_no = Connect.addyh(Connect.yy(evlpidlist.Text.Trim(), any));
                        cmdText = cmdText + " and inp_no in " + "(" + inp_no + ")";
                    }

                    SqlConnection con = new SqlConnection(SQL.constr);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmdText, SQL.constr);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    this.evlsearchresult_list.DataSource = ds.Tables[0].DefaultView;
                    evlsearchresult_list.Columns[0].Visible = false;
                    con.Close();
                }
                else if (evltype2_1.Checked)//选择出院
                {
                    mztype = false;
                    zytype = true;
                    publicclass th = new publicclass();
                    th.tabpageadd(tabControl3, tabPage12);
                    this.tabControl3.SelectedIndex = 1;
                    string cmdText;
                    cmdText = " case_id as 编码,isnull(inp_no,'') as 住院号,isnull(patient_name,'') as 患者,isnull(dept_name,'') as 科室,isnull(doctor_name,'') as 主管医生,isnull(start_date,'') as 入院日期,isnull(end_date,'') as 出院日期,isnull(diagnosis,'') as 入院诊断,isnull(diagnosis2,'') as 出院诊断,'' as 点评结果,'' as 点评时间,'' as 点评人 from dbo.pt_patient_info ";
                    if (richTextBox15.Text != "")
                    {
                        if (radioButton19.Checked)
                        {
                            cmdText = cmdText + " TABLESAMPLE SYSTEM (" + richTextBox15.Text + " PERCENT)";
                        }
                        else if (radioButton20.Checked)
                        {
                            cmdText = cmdText + " TABLESAMPLE SYSTEM (" + richTextBox15.Text + "*0.1 PERCENT)";
                        }
                    }
                    cmdText = cmdText + " where left(case_id,2)='Zy'and case_id not in (select case_id from evaluate_main)";
                    if (evlsearchcount.Text != "")
                    {
                        cmdText = "select top " + evlsearchcount.Text + cmdText;
                    }
                    else
                    {
                        cmdText = "select " + cmdText;
                    }
                    cmdText = cmdText + " and end_date between " + " '" + evlbegindt1.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + evlenddt1.Value.ToString("yyyy-MM-dd") + "'";
                    if (evldeptlist.Text != "")
                    {
                        string dept_name = Connect.addyh(Connect.yy(evldeptlist.Text.Trim(), any));
                        cmdText = cmdText + " and dept_name in" + "(" + dept_name + ")";
                    }
                    if (evldoctorlist.Text != "")
                    {
                        string doctor_name = Connect.addyh(Connect.yy(evldoctorlist.Text.Trim(), any));
                        cmdText = cmdText + " and doctor_name in" + "(" + doctor_name + ")";
                    }
                    if (evlicdlist.Text != "")
                    {
                        string diagnosis = Connect.addyh(Connect.yy(evlicdlist.Text.Trim(), any));
                        cmdText = cmdText + " and diagnosis in" + "(" + diagnosis + ")";
                    }
                    if (evldruglist.Text != "")
                    {
                        cmdText = cmdText + " and case_id in (select case_id from dbo.pt_orders where order_text in (" + evldruglist.Text + ")";
                    }
                    if (evlpnamelist.Text != "")
                    {
                        string patient_name = Connect.addyh(Connect.yy(evlpnamelist.Text.Trim(), any));
                        cmdText = cmdText + " and patient_name in " + "(" + patient_name + ")";
                    }
                    if (evlpidlist.Text != "")
                    {
                        string inp_no = Connect.addyh(Connect.yy(evlpidlist.Text.Trim(), any));
                        cmdText = cmdText + " and inp_no in " + "(" + inp_no + ")";
                    }
                    SqlConnection con = new SqlConnection(SQL.constr);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmdText, SQL.constr);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    this.evlsearchresult_list.DataSource = ds.Tables[0].DefaultView;
                    evlsearchresult_list.Columns[0].Visible = false;
                    con.Close();
                }
            }
            //选择查询点评结果
            else if (evl_ckdpjg.Checked)
            {
                chose1 = false;
                chose2 = true;
                if (evltype1_2.Checked)//选择门（急）诊
                {
                    mztype = true;
                    zytype = false;
                    publicclass th = new publicclass();
                    th.tabpageadd(tabControl3, tabPage12);
                    this.tabControl3.SelectedIndex = 1;
                    string cmdText;
                    cmdText = "select a.case_id as 编码,isnull(a.inp_no,'') as 门诊号,isnull(a.patient_name,'') as 患者,isnull(a.dept_name,'') as 科室,isnull(a.doctor_name,'') as 看诊医生,isnull(a.start_date,'') as 入院日期,isnull(a.end_date,'') as 出院日期,isnull(a.diagnosis,'') as 入院诊断,isnull(a.diagnosis,'') as 出院诊断,b.c_level as 点评结果,b.time as 点评时间,b.user_name as 点评人 from dbo.pt_patient_info a(nolock) left join dbo.evaluate_main b(nolock)on a.case_id=b.case_id where left(a.case_id,2)='Mz' and a.case_id  in (select case_id from dbo.evaluate_main )";
                    cmdText = cmdText + " and b.time between " + " '" + evlbegindt2.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + evlenddt2.Value.ToString("yyyy-MM-dd") + "'";
                    string s = "";
                    if (evl_hl.Checked) { s = s + "0,"; }
                    if (evl_bgf.Checked) { s = s + "1,"; }
                    if (evl_bsy.Checked) { s = s + "2,"; }
                    if (evl_cccf.Checked) { s = s + "3,"; }
                    if (s != "")
                    {
                        s = s.Remove(s.LastIndexOf(","), 1);
                        cmdText = cmdText + " and b.i_level in ( " + s + " )";
                    }
                    if (evlcommentname.Text != "")
                    {
                        string user_name = Connect.addyh(Connect.yy(evlcommentname.Text.Trim(), any));
                        cmdText = cmdText + " and b.user_name in " + "(" + user_name + ")";
                    }

                    SqlConnection con = new SqlConnection(SQL.constr);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmdText, SQL.constr);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    this.evlsearchresult_list.DataSource = ds.Tables[0].DefaultView;
                    evlsearchresult_list.Columns[0].Visible = false;
                    con.Close();
                }
                else if (evltype2_2.Checked)//选择出院
                {
                    mztype = false;
                    zytype = true;
                    publicclass th = new publicclass();
                    th.tabpageadd(tabControl3, tabPage12);
                    this.tabControl3.SelectedIndex = 1;
                    string cmdText;
                    cmdText = "select a.case_id as 编码,isnull(a.inp_no,'') as 住院号,isnull(a.patient_name,'') as 患者,isnull(a.dept_name,'') as 科室,isnull(a.doctor_name,'') as 主管医生,isnull(a.start_date,'') as 入院日期,isnull(a.end_date,'') as 出院日期,isnull(a.diagnosis,'') as 入院诊断,isnull(a.diagnosis,'') as 出院诊断,b.c_level as 点评结果,b.time as 点评时间,b.user_name as 点评人 from dbo.pt_patient_info a(nolock) left join dbo.evaluate_main b(nolock)on a.case_id=b.case_id where left(a.case_id,2)='Zy' and a.case_id  in (select case_id from dbo.evaluate_main )";
                    cmdText = cmdText + " and a.end_date between " + " '" + evlbegindt2.Value.ToString("yyyy-MM-dd") + "'" + " and" + " '" + evlenddt2.Value.ToString("yyyy-MM-dd") + "'";
                    string s = "";
                    if (evl_hl.Checked) { s = s + "0,"; }
                    if (evl_bgf.Checked) { s = s + "1,"; }
                    if (evl_bsy.Checked) { s = s + "2,"; }
                    if (evl_cccf.Checked) { s = s + "3,"; }
                    if (s != "")
                    {
                        s = s.Remove(s.LastIndexOf(","), 1);
                        cmdText = cmdText + " and b.i_level in ( " + s + " )";
                    }
                    if (evlcommentname.Text != "")
                    {
                        cmdText = cmdText + " and b.user_name in" + "('" + evlcommentname.Text + "')";
                    }

                    SqlConnection con = new SqlConnection(SQL.constr);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmdText, SQL.constr);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    this.evlsearchresult_list.DataSource = ds.Tables[0].DefaultView;
                    evlsearchresult_list.Columns[0].Visible = false;
                    con.Close();
                }
            }
            evlsearchresult_list.Columns[3].Width = new Size(130, 30).Width;
            evlsearchresult_list.Columns[7].Width = new Size(130, 30).Width;
            evlsearchresult_list.Columns[8].Width = new Size(130, 30).Width;
        }

        #endregion


        private void yzlb()
        {
            evl_cf_list.Columns[0].Width = new Size(25, 30).Width;
            evl_cf_list.Columns[1].Width = new Size(30, 30).Width;
            evl_cf_list.Columns[2].Width = new Size(25, 30).Width;
            evl_cf_list.Columns[3].Width = new Size(25, 30).Width;
            evl_cf_list.Columns[4].Width = new Size(25, 30).Width;
            evl_cf_list.Columns[5].Width = new Size(25, 30).Width;
            evl_cf_list.Columns[6].Width = new Size(150, 30).Width;
            evl_cf_list.Columns[7].Width = new Size(60, 30).Width;
            evl_cf_list.Columns[9].Width = new Size(80, 30).Width;
            evl_cf_list.Columns[10].Width = new Size(60, 30).Width;
            evl_cf_list.Columns[11].Width = new Size(70, 30).Width;
            evl_cf_list.Columns[12].Width = new Size(80, 30).Width;
            evl_cf_list.Columns[13].Width = new Size(80, 30).Width;
            evl_cf_list.Columns[14].Width = new Size(80, 30).Width;
            evl_cf_list.Columns[15].Width = new Size(80, 30).Width;
            evl_cf_list.Columns[16].Width = new Size(80, 30).Width;
        }


        private void evl_yckj()
        {
            publicclass t1 = new publicclass();
            if (evl_examresult_list.Visible == false)
            {
                evl_panel4.Visible = false;
                t1.yincangkj(evl_panel3, evl_panel11, 1);
                t1.yincangkj(evl_panel11, evl_panel5, 1);
                t1.yincangkj(evl_panel5, evl_panel6, 1);
            }
            if (evl_ss_list.Visible == false)
            {
                evl_panel11.Visible = false;
                if (evl_examresult_list.Visible == false)
                {
                    t1.yincangkj(evl_panel3, evl_panel5, 1);
                    t1.yincangkj(evl_panel5, evl_panel6, 1);
                }
                else if (evl_examresult_list.Visible == true)
                {
                    t1.yincangkj(evl_panel4, evl_panel5, 1);
                    t1.yincangkj(evl_panel5, evl_panel6, 1);
                }
            }
            if (evl_cf_list.Visible == false)
            {
                panel5.Visible = false;
                if (evl_ss_list.Visible == true)
                {
                    t1.yincangkj(evl_panel11, evl_panel6, 1);
                }
                else if (evl_ss_list.Visible == false)
                {
                    if (evl_examresult_list.Visible == true)
                    {
                        t1.yincangkj(evl_panel4, evl_panel6, 1);
                    }
                    else if (evl_examresult_list.Visible == false)
                    {
                        t1.yincangkj(evl_panel3, evl_panel6, 1);
                    }
                }
            }
        }

        private void evl_zkkj()
        {
            evl_examresult_list.Visible = true;
            evl_ss_list.Visible = true;
            evl_cf_list.Visible = true;
            evl_evaluate_list.Visible = true;
            evl_panel3.Visible = true;
            evl_panel4.Visible = true;
            evl_panel11.Visible = true;
            evl_panel5.Visible = true;
            evl_panel6.Visible = true;
            publicclass t1 = new publicclass();
            t1.yincangkj(evl_panel3, evl_panel4, 1);
            t1.yincangkj(evl_panel4, evl_panel11, 1);
            t1.yincangkj(evl_panel11, evl_panel5, 1);
            t1.yincangkj(evl_panel5, evl_panel6, 1);
        }

        //导出EXCEL
        private void evl_outout_result_Click(object sender, EventArgs e)
        {
            SaveAs(evlsearchresult_list);
        }


        #region 初始化控件函数
        private void chushihua(string b)
        {
            if (b == "门诊")
            {
                evl_pid.Text = "门 诊 号:";
                evl_indate.Text = "就诊日期:";
                evl_outdate.Text = "就诊科室:";
                evl_dept.Text = "医    师:";
                evl_bednum.Visible = false;
                evl_bednum_s.Visible = false;
                evl_doctor.Visible = false;
                evl_doctor_s.Visible = false;
                evl_inicd.Text = "临床诊断:";
                evl_outicd.Visible = false;
                evl_outicd_s.Visible = false;
                evl_nurse.Visible = false;
                evl_nurse_s.Visible = false;
                evl_qbyz_choice.Checked = true;
                evl_cf_link.Visible = true;
                label460.Visible = false;
                label463.Visible = false;
                label455.Visible = false;
                label451.Visible = false;
                label239.Text = "";
            }
            if (b == "住院")
            {
                evl_pid.Text = "住院号:";
                evl_indate.Text = "入院日期:";
                evl_outdate.Text = "出院日期:";
                evl_dept.Text = "科    别:";
                evl_bednum.Visible = true;
                evl_bednum_s.Visible = true;
                evl_doctor.Visible = true;
                evl_doctor_s.Visible = true;
                evl_inicd.Text = "入院诊断:";
                evl_outicd.Visible = true;
                evl_outicd_s.Visible = true;
                evl_nurse.Visible = true;
                evl_nurse_s.Visible = true;
                evl_qbyz_choice.Checked = true;
                evl_cf_link.Visible = false;
                label460.Visible = true;
                label463.Visible = true;
                label455.Visible = true;
                label451.Visible = true;
                label239.Text = "";
            }
        }
        #endregion

        #region 处方(医嘱)筛选

        //选择全部医嘱
        private void evl_qbyz_choice_Click(object sender, EventArgs e)
        {
            if (evl_qbyz_choice.Checked)
            {
                string case_id;
                case_id = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();
                cfz = case_id;
                string cmdText4 = "exec [Get_pt_orders]'" + case_id + "','Mz'";
                string cmdText5 = "exec [Get_pt_orders]'" + case_id + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();
                if (mztype)
                {
                    SqlDataAdapter da3 = new SqlDataAdapter(cmdText4, con1);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3);
                    this.evl_cf_list.DataSource = ds3.Tables[0].DefaultView;

                }
                else if (zytype)
                {
                    SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                    DataSet ds4 = new DataSet();
                    da4.Fill(ds4);
                    this.evl_cf_list.DataSource = ds4.Tables[0].DefaultView;
                }
                con1.Close();
            }
            yzlb();
            if (evl_cf_list.Rows.Count == 0)
            {
                evl_cf_list.Visible = false;
            }
            else if (evl_cf_list.Rows.Count > 0)
            {
                evl_cf_list.Visible = true;
            }
        }
        //选择全部药品
        private void evl_qbyp_choice_Click(object sender, EventArgs e)
        {
            if (evl_qbyp_choice.Checked)
            {
                string case_id;
                case_id = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();
                cfz = case_id;
                string cmdText4 = "exec [Get_pt_orders_drug]'" + case_id + "','Mz'";
                string cmdText5 = "exec [Get_pt_orders_drug]'" + case_id + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();
                if (mztype)
                {
                    SqlDataAdapter da3 = new SqlDataAdapter(cmdText4, con1);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3);
                    this.evl_cf_list.DataSource = ds3.Tables[0].DefaultView;

                }
                else if (zytype)
                {
                    SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                    DataSet ds4 = new DataSet();
                    da4.Fill(ds4);
                    this.evl_cf_list.DataSource = ds4.Tables[0].DefaultView;
                }
                con1.Close();
            }
            yzlb();
            if (evl_cf_list.Rows.Count == 0)
            {
                evl_cf_list.Visible = false;
            }
            else if (evl_cf_list.Rows.Count > 0)
            {
                evl_cf_list.Visible = true;
            }
        }
        //选择抗菌药
        private void evl_kjy_choice_Click(object sender, EventArgs e)
        {
            if (evl_kjy_choice.Checked)
            {
                string case_id;
                case_id = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();
                cfz = case_id;
                string cmdText4 = "exec [Get_pt_orders_kjy]'" + case_id + "','Mz'";
                string cmdText5 = "exec [Get_pt_orders_kjy]'" + case_id + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();
                if (mztype)
                {
                    SqlDataAdapter da3 = new SqlDataAdapter(cmdText4, con1);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3);
                    this.evl_cf_list.DataSource = ds3.Tables[0].DefaultView;

                }
                else if (zytype)
                {
                    SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                    DataSet ds4 = new DataSet();
                    da4.Fill(ds4);
                    this.evl_cf_list.DataSource = ds4.Tables[0].DefaultView;
                }
                con1.Close();
            }
            yzlb();
            if (evl_cf_list.Rows.Count == 0)
            {
                evl_cf_list.Visible = false;
            }
            else if (evl_cf_list.Rows.Count > 0)
            {
                evl_cf_list.Visible = true;
            }
        }

        #endregion

        #region 点评信息
        private void dp_info()
        {
            string case_id;
            case_id = evlsearchresult_list.Rows[i].Cells[0].Value.ToString().Trim();
            cfz = case_id;
            SqlConnection con1 = new SqlConnection(SQL.constr);
            con1.Open();
            //点评信息
            string cmdText6 = "select question ,all_id ,'查看/修改' ,'删除' from evaluate_question where case_id='" + case_id + "'";

            SqlDataAdapter da5 = new SqlDataAdapter(cmdText6, con1);
            DataTable dt5 = new DataTable();
            da5.Fill(dt5);
            evl_evaluate_list.Rows.Clear();
            for (int nn = 0; nn < dt5.Rows.Count; nn++)
            {
                evl_evaluate_list.Rows.Add();
                evl_evaluate_list.Rows[nn].Cells[0].Value = dt5.Rows[nn][0].ToString();//问题处理意见
                evl_evaluate_list.Rows[nn].Cells[1].Value = dt5.Rows[nn][1].ToString();//类型
                evl_evaluate_list.Rows[nn].Cells[2].Value = "查看/修改";//查看编辑
                evl_evaluate_list.Rows[nn].Cells[3].Value = "删除";//删除

            }
            this.evl_dpresult_s.Text = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评结果"].Value.ToString();
            this.evl_dppeople_s.Text = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评人"].Value.ToString();
            this.evl_dptime_s.Text = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评时间"].Value.ToString();
            this.evl_evaluate_list.Columns[2].DefaultCellStyle.ForeColor = Color.Blue;
            this.evl_evaluate_list.Columns[3].DefaultCellStyle.ForeColor = Color.Blue;
            this.evl_evaluate_list.Columns[2].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
            this.evl_evaluate_list.Columns[3].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
            con1.Close();
            if (evl_evaluate_list.Rows.Count == 0)
            {
                evl_evaluate_list.Visible = false;
                evl_yes_choice.Checked = true;
                evl_addproblem_link.Visible = false;
            }
            else if (evl_evaluate_list.Rows.Count > 0)
            {
                evl_evaluate_list.Visible = true;
                evl_no_choice.Checked = true;
            }
        }
        #endregion

        #region 病人基本信息
        private void patient_allinfo()
        {
            string case_id;
            case_id = evlsearchresult_list.Rows[i].Cells[0].Value.ToString().Trim();
            cfz = case_id;
            //显示病人基本信息
            string cmdText1 = "exec [Get_Patient_info]'" + case_id + "'";
            string cmdText2 = String.Format("exec [Get_exam_main]'{0}'", case_id);
            string cmdText3 = "exec [Get_operation_info]'" + case_id + "'";
            SqlConnection con1 = new SqlConnection(SQL.constr);
            con1.Open();
            SqlCommand cmd = new SqlCommand(cmdText1, con1);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                evl_pid_s.Text = dr[0].ToString();
                evl_pname_s.Text = dr[1].ToString();
                evl_sex_s.Text = dr[2].ToString();
                evl_birth_s.Text = dr[3].ToString();
                evl_age_s.Text = dr[4].ToString();
                evl_height_s.Text = dr[5].ToString();
                evl_weight_s.Text = dr[6].ToString();
                evl_Identity_s.Text = dr[7].ToString();
                evl_nation_s.Text = dr[8].ToString();
                evl_jg_s.Text = dr[9].ToString();
                evl_workplace_s.Text = dr[10].ToString();
                evl_linkplace_s.Text = dr[11].ToString();
                evl_linktel_s.Text = dr[12].ToString();
                evl_indate_s.Text = dr[13].ToString();
                evl_inicd_s.Text = dr[18].ToString();
                evl_gms_s.Text = dr[20].ToString();
                evl_costtype_s.Text = dr[22].ToString();
                if (mztype)
                {
                    evl_outdate_s.Text = dr[15].ToString();
                    evl_dept_s.Text = dr[17].ToString();
                }
                if (zytype)
                {
                    evl_outdate_s.Text = dr[14].ToString();
                    evl_dept_s.Text = dr[15].ToString();
                    evl_bednum_s.Text = dr[16].ToString();
                    evl_doctor_s.Text = dr[17].ToString();
                    evl_outicd_s.Text = dr[19].ToString();
                    evl_nurse_s.Text = dr[21].ToString();
                }
            }
            dr.Close();
            //检验检查信息
            SqlDataAdapter da1 = new SqlDataAdapter(cmdText2, con1);
            DataSet ds1 = new DataSet();
            da1.Fill(ds1);
            this.evl_examresult_list.DataSource = ds1.Tables[0].DefaultView;
            evl_examresult_list.Columns[0].Width = new Size(210, 30).Width;
            evl_examresult_list.Columns[1].Width = new Size(210, 30).Width;
            evl_examresult_list.Columns[2].Width = new Size(210, 30).Width;
            evl_examresult_list.Columns[3].Width = new Size(210, 30).Width;
            evl_examresult_list.Columns[4].Width = new Size(210, 30).Width;
            if (evl_examresult_list.Rows.Count == 0)
            {
                evl_examresult_list.Visible = false;
            }
            else if (evl_examresult_list.Rows.Count > 0)
            {
                evl_examresult_list.Visible = true;
            }
            //手术信息
            SqlDataAdapter da2 = new SqlDataAdapter(cmdText3, con1);
            DataSet ds2 = new DataSet();
            da2.Fill(ds2);
            this.evl_ss_list.DataSource = ds2.Tables[0].DefaultView;
            if (mztype)
            {
                chushihua("门诊");
            }
            else if (zytype)
            {
                chushihua("住院");
            }
            con1.Close();
            evl_ss_list.Columns[0].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[1].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[2].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[3].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[4].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[5].Width = new Size(150, 30).Width;
            evl_ss_list.Columns[6].Width = new Size(150, 30).Width;
            if (evl_ss_list.Rows.Count == 0)
            {
                evl_ss_list.Visible = false;
            }
            else if (evl_ss_list.Rows.Count > 0)
            {
                evl_ss_list.Visible = true;
            }
        }
        #endregion



        #region 上例下例
        //上例
        private void evl_dpup_Click(object sender, EventArgs e)
        {
            evl_zkkj();
            label239.Text = "";
            i = evlsearchresult_list.CurrentRow.Index;
            evlsearchresult_list.Rows[i].Selected = false;
            if (i > 0)
            {
                evlsearchresult_list.CurrentCell = evlsearchresult_list.Rows[i - 1].Cells[1];
                i -= 1;
            }
            else if (i == 0)
            {
                evlsearchresult_list.CurrentCell = evlsearchresult_list.Rows[evlsearchresult_list.Rows.Count - 1].Cells[1];
                i = evlsearchresult_list.Rows.Count - 1;
            }
            evlsearchresult_list.Rows[i].Selected = true;
            patient_allinfo();
            dp_info();
            evl_qbyz_choice_Click(sender, e);
            evl_yckj();
        }
        //下例
        private void evl_dpdown_Click(object sender, EventArgs e)
        {
            evl_zkkj();
            label239.Text = "";
            i = evlsearchresult_list.CurrentRow.Index;
            evlsearchresult_list.Rows[i].Selected = false;
            if (i < evlsearchresult_list.Rows.Count - 1)
            {
                evlsearchresult_list.CurrentCell = evlsearchresult_list.Rows[i + 1].Cells[1];
                i += 1;
            }
            else
            {
                evlsearchresult_list.CurrentCell = evlsearchresult_list.Rows[0].Cells[1];
                i = 0;
            }
            evlsearchresult_list.Rows[i].Selected = true;
            patient_allinfo();
            dp_info();
            evl_qbyz_choice_Click(sender, e);
            evl_yckj();         
        }
        #endregion


        #region 查看处方
        private void evl_cf_link_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(SQL.constr);
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "select count(*) from pt_orders  where order_class='1' and case_id='" + cfz + "'";
            con.Open();
            if ((int)cmd.ExecuteScalar() == 0)
            {
                //MessageBox.Show("无处方内容", "系统提示");
                label239.Text = "无处方内容";
            }
            else if ((int)cmd.ExecuteScalar() > 0)
            {
                Form chufang = new chufang();
                chufang.ShowDialog();
            }
        }
        #endregion


        #region 双击datagridview显示病人详细信息
        private void evlsearchresult_list_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            evl_zkkj();
            publicclass th = new publicclass();
            th.tabpageadd(tabControl3, tabPage13);
            label239.Text = "";
            i = evlsearchresult_list.CurrentRow.Index;
            patient_allinfo();
            evl_qbyz_choice_Click(sender, e);
            dp_info();
            this.tabControl3.SelectedIndex = 2;
            evl_yckj();
        }
        #endregion

        #region 双击显示病人检验结果明细
        private void evl_examresult_list_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DangQianHang.aa = evl_examresult_list.Rows[evl_examresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = evl_examresult_list.Rows[evl_examresult_list.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            jianyanxiagnxi.ShowDialog();
        }

        #endregion


        private void evl_no_choice_CheckedChanged(object sender, EventArgs e)
        {
            if (evl_no_choice.Checked)
            {
                evl_addproblem_link.Visible = true;
                evl_evaluate_list.Visible = true;
            }
            else if (evl_yes_choice.Checked)
            {
                evl_addproblem_link.Visible = false;
                evl_evaluate_list.Visible = false;
            }
        }


        #region 处方(医嘱)点评
        //新增问题
        private void evl_addproblem_link_Click(object sender, EventArgs e)
        {
            evl_allid = "";
            evl_question = "";
            evlform eve = new evlform();

            eve.button1.Click += new EventHandler(
              (sender1, e1) =>
              {
                  this.evl_evaluate_list.Rows.Add();
                  this.evl_evaluate_list.Rows[this.evl_evaluate_list.Rows.Count - 1].Cells[1].Value = evl_allid;
                  this.evl_evaluate_list.Rows[this.evl_evaluate_list.Rows.Count - 1].Cells[0].Value = evl_question;
              }
                            );

            evl_evaluate_list.Columns[2].DefaultCellStyle.ForeColor = Color.Blue;
            evl_evaluate_list.Columns[3].DefaultCellStyle.ForeColor = Color.Blue;
            evl_evaluate_list.Columns[2].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
            evl_evaluate_list.Columns[3].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
            eve.ShowDialog();
            evl_evaluate_list.CurrentCell = evl_evaluate_list.Rows[evl_evaluate_list.Rows.Count - 1].Cells[0];
            evl_evaluate_list.Rows[evl_evaluate_list.Rows.Count - 1].Cells[2].Value = "查看/修改";
            evl_evaluate_list.Rows[evl_evaluate_list.Rows.Count - 1].Cells[3].Value = "删除";
        }

        //修改、编辑、删除
        private void evl_evaluate_list_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                Form evlform = new evlform();
                evl_allid = evl_evaluate_list.Rows[evl_evaluate_list.CurrentRow.Index].Cells[1].Value.ToString();
                evl_question = evl_evaluate_list.Rows[evl_evaluate_list.CurrentRow.Index].Cells[0].Value.ToString();
                evlform.ShowDialog();
                evl_evaluate_list.Rows[evl_evaluate_list.CurrentRow.Index].Cells[1].Value = evl_allid;
                evl_evaluate_list.Rows[evl_evaluate_list.CurrentRow.Index].Cells[0].Value = evl_question;

            }
            if (e.ColumnIndex == 3)
            {
                evl_evaluate_list.Rows.RemoveAt(evl_evaluate_list.CurrentRow.Index);
            }
        }

        //重新点评
        private void evl_dpreturn_Click(object sender, EventArgs e)
        {
            dp_info();
        }

        //保存到detail表中
        private void insertdetail(string a, string b)
        {
            string case_id;
            case_id = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            SqlConnection con1 = new SqlConnection(SQL.constr);
            //a = a + "；";
            if (a.IndexOf(b) >= 0)
            {
                if (b.LastIndexOf("；") >= 0)
                {
                    b = b.Remove(b.LastIndexOf("；"), 1);
                }
                string cmdText6 = "insert into evaluate_detail select '" + case_id + "','" + b + "',evl_desc from dict_evaluate where evl_id='" + b + "'";
                SqlCommand cmd6 = new SqlCommand(cmdText6, con1);
                con1.Open();
                cmd6.ExecuteNonQuery();
                con1.Close();
            }
        }

        //保存点评
        private void evl_dpsave_Click(object sender, EventArgs e)
        {
            string case_id;
            case_id = evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            SqlConnection con1 = new SqlConnection(SQL.constr);
            con1.Open();
            string cmdText1 = "delete from evaluate_question where case_id='" + case_id + "'";
            SqlCommand cmd1 = new SqlCommand(cmdText1, con1);
            cmd1.ExecuteNonQuery();
            string cmdText2 = "delete from evaluate_main where case_id='" + case_id + "'";
            SqlCommand cmd2 = new SqlCommand(cmdText2, con1);
            cmd2.ExecuteNonQuery();
            string cmdText3 = "delete from evaluate_detail where case_id='" + case_id + "'";
            SqlCommand cmd3 = new SqlCommand(cmdText3, con1);
            cmd3.ExecuteNonQuery();
            if (evl_yes_choice.Checked)
            {
                string sqlcmd = "insert into evaluate_main values('" + case_id + "','" + name1 + "','" + name2 + "',convert(varchar(10),getdate(),121),'0','合理处方')";
                SqlCommand cmd = new SqlCommand(sqlcmd, con1);
                cmd.ExecuteNonQuery();
                con1.Close();
                evl_dpresult_s.Text = "合理处方";
                evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评结果"].Value = "合理处方";
                evl_dptime_s.Text = System.DateTime.Now.ToShortDateString().ToString();
                evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评时间"].Value = System.DateTime.Now.ToShortDateString().ToString();
                evl_dppeople_s.Text =name2;
                MessageBox.Show("点评结果保存成功", "恭喜");
            }
            else if (evl_no_choice.Checked)
            {
                string m = "";
                for (int i = 0; i < evl_evaluate_list.Rows.Count; i++)
                {
                    evl_question = evl_evaluate_list.Rows[i].Cells[0].Value.ToString();
                    evl_allid = evl_evaluate_list.Rows[i].Cells[1].Value.ToString();
                    string cmdText4 = "insert into evaluate_question values ('" + case_id + "','" + evl_allid + "','" + evl_question + "')";
                    SqlCommand cmd4 = new SqlCommand(cmdText4, con1);
                    cmd4.ExecuteNonQuery();
                    m = m + evl_allid + "；";

                }
                if (m.IndexOf("(3)") >= 0)
                {
                    string cmdText5 = "insert into evaluate_main values('" + case_id + "','" + name1 + "','" + name2 + "',convert(varchar(10),getdate(),121),'3','超常处方')";
                    SqlCommand cmd5 = new SqlCommand(cmdText5, con1);
                    cmd5.ExecuteNonQuery();
                    con1.Close();
                    evl_dpresult_s.Text = "超常处方";
                    evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评结果"].Value = "超常处方";
                }
                else if (m.IndexOf("(2)") >= 0)
                {
                    string cmdText5 = "insert into evaluate_main values('" + case_id + "','" + name1 + "','" + name2 + "',convert(varchar(10),getdate(),121),'2','用药不适宜处方')";
                    SqlCommand cmd5 = new SqlCommand(cmdText5, con1);
                    cmd5.ExecuteNonQuery();
                    con1.Close();
                    evl_dpresult_s.Text = "用药不适宜处方";
                    evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评结果"].Value = "用药不适宜处方";
                }
                else if (m.IndexOf("(1)") >= 0)
                {
                    string cmdText5 = "insert into evaluate_main values('" + case_id + "','" + name1 + "','" + name2 + "',convert(varchar(10),getdate(),121),'1','不规范处方')";
                    SqlCommand cmd5 = new SqlCommand(cmdText5, con1);
                    cmd5.ExecuteNonQuery();
                    con1.Close();
                    evl_dpresult_s.Text = "不规范处方";
                    evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评结果"].Value = "不规范处方";
                }
                insertdetail(m, "(1)1-1；"); insertdetail(m, "(1)1-2；"); insertdetail(m, "(1)1-3；");
                insertdetail(m, "(1)1-4；"); insertdetail(m, "(1)1-5；"); insertdetail(m, "(1)1-6；");
                insertdetail(m, "(1)1-7；"); insertdetail(m, "(1)1-8；"); insertdetail(m, "(1)1-9；");
                insertdetail(m, "(1)1-10；"); insertdetail(m, "(1)1-11；"); insertdetail(m, "(1)1-12；");
                insertdetail(m, "(1)1-13；"); insertdetail(m, "(1)1-14；"); insertdetail(m, "(1)1-15；");
                insertdetail(m, "(2)1-1；"); insertdetail(m, "(2)1-2；"); insertdetail(m, "(2)1-3；");
                insertdetail(m, "(2)1-4；"); insertdetail(m, "(2)1-5；"); insertdetail(m, "(2)1-6；");
                insertdetail(m, "(2)1-7；"); insertdetail(m, "(2)1-8；"); insertdetail(m, "(2)1-9；");
                insertdetail(m, "(3)1-1；"); insertdetail(m, "(3)1-2；"); insertdetail(m, "(3)1-3；"); insertdetail(m, "(3)1-4；");
                evl_dptime_s.Text = System.DateTime.Now.ToShortDateString().ToString();
                evl_dppeople_s.Text = name2;
                evlsearchresult_list.Rows[evlsearchresult_list.CurrentRow.Index].Cells["点评时间"].Value = System.DateTime.Now.ToShortDateString().ToString();
                MessageBox.Show("点评结果保存成功", "恭喜");
            }
        }

        #endregion

        // evl tanqianyun end

        //用户管理模块 by tanqianyun
        #region 用户管理
        //显示用户信息
        private void showuser()
        {
            if (tabControl1.SelectedTab == tabPage7)
            {
                SqlConnection con1 = new SqlConnection(SQL.constr);
                string cmdText2 = "select a.user_name as 登录名,c.name as 姓名,c.title as 职称,c.dept_name as 所属科室,'查看/修改' as 编辑,'删除' as 删除权限 from sys_sys_users a(nolock)  left join dict_employee c(nolock) on a.emp_sn=c.emp_sn";
                SqlDataAdapter da2 = new SqlDataAdapter(cmdText2, con1);
                DataSet ds2 = new DataSet();
                con1.Open();
                da2.Fill(ds2);
                con1.Close();
                user_list.DataSource = ds2.Tables[0].DefaultView;
                this.user_list.Columns[4].DefaultCellStyle.ForeColor = Color.Blue;
                this.user_list.Columns[5].DefaultCellStyle.ForeColor = Color.Blue;
                this.user_list.Columns[4].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
                this.user_list.Columns[5].DefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Underline);
                user_list.Columns[0].Width = new Size(80, 30).Width;
                user_list.Columns[1].Width = new Size(80, 30).Width;
                user_list.Columns[2].Width = new Size(80, 30).Width;
                user_list.Columns[3].Width = new Size(100, 30).Width;
                user_list.Columns[4].Width = new Size(80, 30).Width;
                user_list.Columns[5].Width = new Size(80, 30).Width;
            }
            treeView1.CheckBoxes = true;
            treeView1.ExpandAll();
        }
        #region  //锁定系统方法
        void flock_hide_main(bool hide)
        {
            if (hide == true)
            {
                this.Show();
            }
        }
        #endregion
        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
           
            
            showuser();
        }
        private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
        {
            SetCheck(e.Node);
        }
        private void SetCheck(TreeNode node)
        {
            if (node.Nodes.Count > 0)
            {
                foreach (TreeNode tn in node.Nodes)
                {
                    tn.Checked = node.Checked;
                    SetCheck(tn);
                }
            }
        }

        //切换用户时执行的事件
        private void user_list_SelectionChanged(object sender, EventArgs e)
        {
            user_panel7.Enabled = false;
            treeView1.Enabled = false;
            dataGridView8.Visible = false;
            qktree();
        }
        //编辑、查看、修改用户权限
        private void user_list_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                user_panel7.Enabled = true;
                user_name.Enabled = false;
                user_name.ReadOnly = true;
                treeView1.Enabled = true;
                user_name.Text = user_list.Rows[user_list.CurrentRow.Index].Cells[0].Value.ToString();
                employee_name.Text = user_list.Rows[user_list.CurrentRow.Index].Cells[1].Value.ToString();
                qktree();
                using (SqlConnection sql = new SqlConnection(zifuc))
                {
                    ArrayList any = new ArrayList();
                    sql.Open();
                    SqlCommand one = sql.CreateCommand();
                    one.CommandText = "select a.action_name,b.pass_word from sys_sys_func a, sys_sys_users b  where a.subsys_code=b.user_name and  a.subsys_code ='" + user_name.Text + "'";
                    SqlDataReader dr = one.ExecuteReader();
                    while (dr.Read())
                    {
                        any = publicclass.yy(dr[0].ToString(), any);
                        treeView1.Nodes[Convert.ToInt16(any[0]) - 1].Nodes[Convert.ToInt16(any[1]) - 1].Checked = true;
                        any.Clear();
                        passworld.Text = dr[1].ToString(); password_2.Text = dr[1].ToString();
                    }
                    sql.Close();

                }
            }
            else if (e.ColumnIndex == 5)
            {
                qktree();
                scqx(user_list.Rows[user_list.CurrentRow.Index].Cells[0].Value.ToString().Trim());
                passworld.Text = ""; password_2.Text = "";
            }
        }
        //清空树
        private void qktree()
        {
            for (int i = 0; i < treeView1.Nodes.Count; i++)
            {
                for (int j = 0; j < treeView1.Nodes[i].Nodes.Count; j++)
                {
                    treeView1.Nodes[i].Nodes[j].Checked = false;
                }
                treeView1.Nodes[i].Checked = false;
            }
        }
        //保存用户权限
        private void save_js_Click(object sender, EventArgs e)
        {
            if (user_name.ReadOnly == false)//新增用户时保存
            {
                int tc = -1;
                string kc = "select c.emp_sn from dict_employee c(nolock) where c.emp_sn not in (select emp_sn from sys_sys_users) and c.py_code='" + user_name.Text.Trim() + "'";
                try
                {
                    SqlConnection con1 = new SqlConnection(SQL.constr);
                    con1.Open();
                    SqlCommand cmd1 = new SqlCommand(kc, con1);

                    if (cmd1.ExecuteScalar() == null)
                        tc = -1;
                    else tc = Convert.ToInt16(cmd1.ExecuteScalar().ToString());
                    con1.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                }
                if (tc == -1)//判断用户是否在医院用户且此用户不是PASS的用户
                {
                    MessageBox.Show("没有这个用户，请查证再添加");
                    return;
                }
                else
                {
                    if (passworld.Text == "" || password_2.Text == "" || passworld.Text != password_2.Text)
                    {
                        MessageBox.Show("没有输入密码或者两次输入密码不一致");
                        return;
                    }
                    kc = "INSERT INTO sys_sys_users VALUES('" + user_name.Text + "','" + passworld.Text + "',0,'PASS',' " + DateTime.Now.ToString() + " ',null,null,'" + tc.ToString() + " ','1')";
                    try
                    {
                        SqlConnection con1 = new SqlConnection(SQL.constr);
                        con1.Open();
                        SqlCommand cmd1 = new SqlCommand(kc, con1);
                        cmd1.ExecuteScalar();
                        con1.Close();
                        MessageBox.Show("新增用户保存成功");
                        user_panel7.Enabled = false;
                        dataGridView8.Visible = false;
                        showuser();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return;
                    }
                }
                return;
            }
            if (passworld.Text == "" || password_2.Text == "" || passworld.Text != password_2.Text)
            {
                MessageBox.Show("没有输入密码或者两次输入密码不一致");
                return;
            }
            if (user_name.ReadOnly == true)
            {
                string kc = "update sys_sys_users set pass_word='" + passworld.Text + "' where user_name='" + user_name.Text + "'";
                try
                {
                    SqlConnection con1 = new SqlConnection(SQL.constr);
                    con1.Open();
                    SqlCommand cmd1 = new SqlCommand(kc, con1);
                    cmd1.ExecuteScalar();
                    con1.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                }
            }
            user_panel7.Enabled = false;
            treeView1.Enabled = false;
            dataGridView8.Visible = false;
            bool p = false;
            for (int jjj = 0; jjj < treeView1.Nodes.Count; jjj++)
            {
                for (int kkk = 0; kkk < treeView1.Nodes[jjj].Nodes.Count; kkk++)
                    p = (p || treeView1.Nodes[jjj].Nodes[kkk].Checked);
            }
            if (p)
            {
                scqx(user_name.Text);
            }
            for (int i = 0; i < treeView1.Nodes.Count; i++)
            {
                for (int j = 0; j < treeView1.Nodes[i].Nodes.Count; j++)
                {
                    if (treeView1.Nodes[i].Nodes[j].Checked)
                    {
                        string k = (i + 1).ToString() + "-" + (j + 1).ToString();
                        string l = treeView1.Nodes[i].Nodes[j].Text;
                        string m = "INSERT INTO sys_sys_func VALUES ('" + user_name.Text + "','" + k + "','" + l + "',1)";
                        publicclass.zxsqlyj(m, SQL.constr);
                    }
                }
            }
            user_panel7.Enabled = false;
            MessageBox.Show("保存成功");
            dataGridView8.Visible = false;
        }
        //删除后台数据库用户权限
        //参数a 是用户的登录名
        private void scqx(string a)
        {
            string n = "delete from sys_sys_func where subsys_code ='" + a + "'";
            publicclass.zxsqlyj(n, SQL.constr);
        }
        int firsttime = 0;
        DataSet ds;
        private void add_js_Click(object sender, EventArgs e)
        {
            getData();
            user_name.ReadOnly = false;
            employee_name.ReadOnly = true;
            user_name.Text = "";
            employee_name.Text = "";
            passworld.Text = "";
            password_2.Text = "";
            user_panel7.Enabled = true;
            treeView1.Enabled = false;
        }
        private void getData()
        {
            SqlConnection conn = new SqlConnection(SQL.constr);
            try
            {
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter("select c.py_code as 拼音码,c.name as 姓名 from dict_employee c(nolock) where c.emp_sn not in (select emp_sn from sys_sys_users)", conn);
                ds = new DataSet();
                da.Fill(ds);
                this.dataGridView18.DataSource = ds.Tables[0].DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show("error!" + ex.ToString());
                Application.Exit();
            }
            finally
            {
                conn.Close();
            }
        }

        private void dataGridView18_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            this.user_name.Text = this.dataGridView18.CurrentRow.Cells[0].Value.ToString();
            this.employee_name.Text = this.dataGridView18.CurrentRow.Cells[1].Value.ToString();
            this.dataGridView18.Visible = false;
        }

        private void dataGridView18_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.user_name.Text = this.dataGridView18.CurrentRow.Cells[0].Value.ToString();
                this.employee_name.Text = this.dataGridView18.CurrentRow.Cells[1].Value.ToString();
                this.dataGridView18.Visible = false;
            }
        }

        private void user_name_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Down)
            {
                dataGridView18.Focus();
                if (dataGridView18.CurrentRow.Index + 1 < dataGridView18.Rows.Count)
                {
                    dataGridView18.CurrentCell = dataGridView18[0, dataGridView18.CurrentRow.Index + 1];
                }
            }

            if (e.KeyCode == Keys.Enter)
            {
                this.user_name.Text = this.dataGridView18.CurrentRow.Cells[0].Value.ToString();
                this.employee_name.Text = this.dataGridView18.CurrentRow.Cells[1].Value.ToString();
                this.dataGridView18.Visible = false;
            }
        }

        private void user_name_TextChanged(object sender, EventArgs e)
        {
            if (user_name.ReadOnly)
                return;
            employee_name.Text = "";
            this.dataGridView18.Top = this.user_name.Top + this.user_name.Height;
            if (firsttime == 0)
            {
                firsttime = 1;
                getData();
            }
            if (user_name.Text == " ")
            {
                if (ds.Tables[0].DefaultView.Count != 0)
                    dataGridView18.Visible = true;
            }
            else
                ds.Tables[0].DefaultView.RowFilter = "拼音码 like'" + user_name.Text.Trim() + "%'";

            if (ds.Tables[0].DefaultView.Count != 0)
            {
                dataGridView18.Visible = true;
            }
            else
                dataGridView18.Visible = false;
        }
        private void delete_js_Click(object sender, EventArgs e)
        {
            string username = user_list.Rows[user_list.CurrentRow.Index].Cells[0].Value.ToString();
            scqx(username);
            string kc = "delete from sys_sys_users where user_name='" + username + "'";
            scqx(user_name.Text);
            publicclass.zxsqlyj(kc, SQL.constr);
            MessageBox.Show("删除成功");
            showuser();
        }
        #endregion

        //user end

        #region 抗菌药物临床应用医嘱明细检验详细情况
        private void dataGridView13_DoubleClick(object sender, EventArgs e)
        {
            //Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            //jianyanxiagnxi.ShowDialog();
            //string myID;
            //DangQianHang.aa = dataGridView13.Rows[dataGridView13.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.aa = dataGridView13.Rows[dataGridView13.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = dataGridView13.Rows[dataGridView13.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            jianyanxiagnxi.ShowDialog();
        }
        #endregion

        #region 新增调查表
        public static int tk = 0;
        private void button32_Click(object sender, EventArgs e)
        {
            xb = label273.Text;
            nl = label269.Text;
            tz = label265.Text;
            rysj = label255.Text;
            cysj = label256.Text;
            shmc = dataGridView14.Rows[0].Cells[0].Value.ToString();
            qklx = dataGridView14.Rows[0].Cells[3].Value.ToString();
            rysj1 = label255.Text;
            cysj1 = label256.Text;
            blh = label246.Text;
            cyzd = label243.Text;
            ssks01 = label253.Text;
            dept01 = dept_name;//权限名赋值

            tk = 1;//新增调查表
            // linkLabel28.Visible = true;

            DiaoChaBiao2 diaocha2 = new DiaoChaBiao2();
            diaocha2.toolStripButton2.Enabled = false;
            //委托事件
            //diaocha2.toolStripButton3.Click += new EventHandler(
            diaocha2.toolStripButton1.Click += new EventHandler(
              (sender1, e1) =>
              {
                  button32.Enabled = false;
              }
          );
            diaocha2.ShowDialog();
          
            
           
           
           

        }
        #endregion


        private void linkLabel28_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DiaoChaBiao2 diaochabiao22 = new DiaoChaBiao2();
            diaochabiao22.ShowDialog();
            tk = 2;//查看或修改调查表

        }
      
        private void button33_Click(object sender, EventArgs e)
        {
            DianZiYaoLi dianziyaoli = new DianZiYaoLi();
            dianziyaoli.toolStripButton2.Enabled = false;
            dept01 = name2;//权限名赋值到电子药历窗口

            //委托事件
             dianziyaoli.toolStripButton1.Click += new EventHandler(
                  (sender1, e1) =>
                  {
                      button33.Enabled = false;
                  }
              );
            dianziyaoli.ShowDialog();
            

        }

        private void tabControl6_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl6.SelectedIndex == 1)
            {
                DangQianHang hhh = new DangQianHang();
                hhh.change_button(label246.Text);
                if (DangQianHang.i == 1)
                {
                    button32.Enabled = false;
                }
            }



        }

        private void button34_Click(object sender, EventArgs e)
        {
            DiaoChaBiao2 diaochabiao22 = new DiaoChaBiao2();
            diaochabiao22.toolStripButton1.Enabled = false;
            diaochabiao22.ShowDialog();
            tk = 2;//查看或修改调查表
            
        }

        private void button35_Click(object sender, EventArgs e)
        {
            DianZiYaoLi yaoli = new DianZiYaoLi();
            yaoli.toolStripButton1.Enabled = false;
            dept01 = name2;//权限名赋值到电子药历窗口
            yaoli.ShowDialog();
            //dept01 = dept_name;//权限名赋值到电子药历窗口


        }
        //清空查询条件
        private void button41_Click(object sender, EventArgs e)
        {
            richTextBox17.Text = ""; richTextBox18.Text = ""; richTextBox19.Text = ""; richTextBox20.Text = "";
            richTextBox21.Text = ""; richTextBox22.Text = ""; textBox9.Text = ""; keshi = ""; yisheng = ""; zhenduan = "";
            yaopin = ""; checkBox50.Checked = false; checkBox52.Checked = false; richTextBox16.Text = ""; yonghu = "";
        }
        //查询病人
        private void button42_Click(object sender, EventArgs e)
        {
            if (radioButton21.Checked)//根据病人信息查询
            {//将科室等条件转换成sql语句
                keshi = Connect.baozhuang(Connect.yy(richTextBox22.Text.Trim(), any), "a.dept_name");
                zhenduan = Connect.baozhuang(Connect.yy(richTextBox20.Text.Trim(), any), "a.diagnosis");
                yisheng = Connect.baozhuang(Connect.yy(richTextBox21.Text.Trim(), any), "a.doctor_name");
                yaopin = Connect.baozhuang(Connect.yy(richTextBox19.Text.Trim(), any), "b.order_text");
                string starttime, endtime;
                starttime = dateTimePicker26.Text.ToString();
                endtime = dateTimePicker25.Text.ToString();
                string tjtime = "";
                string leixing = "";
                if (radioButton23.Checked)
                {
                    tjtime = " and start_date between '" + starttime + "' and '" + endtime + "' ";
                    leixing = " and case_id like 'mz%'";
                }
                if (radioButton22.Checked)
                {
                    tjtime = " and end_date between '" + starttime + "' and '" + endtime + "' ";
                    leixing = " and a.case_id like 'zy%' and a.end_date is not null ";
                }
                if (richTextBox17.Text == "")
                {
                    leixing += Connect.baozhuang(Connect.yy(richTextBox17.Text, any), "a.inp_no");
                }
                if (richTextBox18.Text == "")
                {
                    leixing += Connect.baozhuang(Connect.yy(richTextBox18.Text, any), "a.patient_name");
                }
                string mun = "30";
                if (textBox9.Enabled == true)
                {
                    mun = textBox9.Text.Trim();
                }
                string shifougr = "";
                if (radioButton26.Checked)
                {
                    shifougr = " and diagnosis in (select DISTINCT a.icd_name from pt_icd_info a,dict_icd b where a.icd_code=b.icd_code and b.i_gr in ('1','2','3','4'))";
                }
                string cyfangs = " ";
                if (radioButton28.Checked)
                {
                    cyfangs = " order by newid() ";
                }
                sqlyuj2 = " where 1=1 " + tjtime + keshi + zhenduan + yisheng + shifougr + leixing;
                if (textBox10.Enabled)
                {
                    if (radioButton24.Checked)
                    {
                        double a = Convert.ToInt16(textBox10.Text.Trim()) * 0.01;
                        mun = "(cast(((select count(*) from zhiliaoyongyao" + sqlyuj2 + " )* " + a.ToString() + ") as int))";
                    }
                    else if (radioButton25.Checked)
                    {
                        double a = Convert.ToInt16(textBox10.Text.Trim()) * 0.001;
                        mun = "(cast(((select count(*) from zhiliaoyongyao" + sqlyuj2 + " )* " + a.ToString() + ") as int))";
                    }
                    sqlyuj2 = "";
                }

                sqlyuj1 = "select  top " + mun + " a.case_id as '住院号',a.patient_name as '病人姓名',a.dept_name as '科室',a.diagnosis as '入院诊断',a.diagnosis2 as '出院诊断',a.user_name as '点评人',a.time as '点评时间',a.c_level as '点评结果'  from zhiliaoyongyao a ";
                sqlyuj2 = " where 1=1 " + tjtime + keshi + zhenduan + yisheng + shifougr + leixing + cyfangs;
                if (radioButton30.Checked)
                {
                    if (richTextBox21.Text.Trim() == "")
                    {
                        MessageBox.Show("没有选择医生，请先选择开医嘱的医生");
                        return;
                    }
                    string b;
                    ArrayList a = new ArrayList();
                    a = Connect.yy(richTextBox21.Text.Trim(), a);
                    b = "where 1=1 " + keshi + zhenduan + shifougr + leixing;
                    DataTable bl = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2).Clone();
                    biao = bl.Clone();
                    object[] obj = new object[bl.Columns.Count];

                    foreach (string i in a)
                    {
                        sqlyuj2 = b + "and a.doctor_name ='" + i + "' order by newid()";

                        bl = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                        for (int kt = 0; kt < bl.Rows.Count; kt++)
                        {
                            bl.Rows[kt].ItemArray.CopyTo(obj, 0);
                            biao.Rows.Add(obj);
                        }
                    }
                }
                else
                {
                    biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                }

            }
            else//根据点评结果查询
            {
                string yongh = "";
                if (richTextBox16.Text.Trim() != "")
                {
                    yongh = " and a.user_name in (" + richTextBox16.Text.Trim() + ")";
                }
                sqlyuj1 = "select  a.case_id as '住院号',a.patient_name as '病人姓名',a.dept_name as '科室',a.diagnosis as '入院诊断',a.diagnosis2 as '出院诊断',a.user_name as '点评人',a.time as '点评时间',a.c_level as '点评结果'  from zhiliaoyongyao a,zl_main b";
                string tiaojian = "";
                if (radioButton29.Checked)
                {
                    tiaojian += "and a.case_id like 'mz%' and a.start_date between '" + dateTimePicker28.Text + "' and '" + dateTimePicker27.Text + "'";
                }
                if (radioButton33.Checked)
                {
                    tiaojian += "and a.case_id like 'zy%' and a.end_date between '" + dateTimePicker28.Text + "' and '" + dateTimePicker27.Text + "'";
                }
                if (checkBox50.Checked && checkBox52.Checked == false)
                {
                    tiaojian += " and b.i_level=0 ";
                }
                if (checkBox52.Checked && checkBox50.Checked == false)
                {
                    tiaojian += " and b.i_level=1 ";
                }
                sqlyuj2 = " where a.case_id=b.case_id " + tiaojian + yongh;
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);

            }
            this.dataGridView15.DataSource = biao;
            //添加标签
            bool dand = true;
            foreach (TabPage k in tabControl5.TabPages)
            {
                if (k.Name == "tabPage18")
                    dand = false;
            }
            if (dand)
            {
                tabControl5.TabPages.Add(tabPage18);
            }
            this.tabControl5.SelectedTab = this.tabPage18;
            keshi = "";//清空中间数据
            yaopin = "";
            zhenduan = "";
            yisheng = "";
            cny.Clear();
        }

        private void button40_Click(object sender, EventArgs e)
        {
            Form choseuser = new dian_ping_ren();
            choseuser.ShowDialog();
            if (yonghu != "")
            {
                yonghu = yonghu.Remove(yonghu.LastIndexOf(","), 1);
            }
            richTextBox16.Text = yonghu;
            yonghu = "";
        }

        private void dataGridView15_DoubleClick(object sender, EventArgs e)
        {

            string sqlyuj1, sqlyuj2;
            DataTable biao;
            int i = dataGridView15.CurrentRow.Index;
            xh4 = i;
            string row1 = dataGridView15.Rows[i].Cells[0].Value.ToString();//获得当前选中的记录的住院号
            ht = row1;
            Label[] labe = new Label[22] { label362, label398, label396, label394, label392, label390, label388, label386, label384, label373, label382, label365, label374, label375, label369, label368, label366, label367, label359, label363, label364, label360 };
            //根据住院号将病人的基本信息检索出来，写进标签中
            using (SqlConnection sql = new SqlConnection(zifuc))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = "SELECT inp_no, patient_name, sex, birth_date, age, body_height, body_weight, idnum, nation, workplace, linkplace, linktel, start_date, end_date, dept_name, bed_no, doctor_name, diagnosis, diagnosis2, allergen, nurse_class, pay_class FROM pt_patient_info where case_id ='" + row1 + "'";
                SqlDataReader dr = one.ExecuteReader();
                dr.Read();
                if (dr != null)
                {
                    for (int j = 0; j < 22; j++)
                    {
                        labe[j].Text = dr[j].ToString();
                    }
                }

                sql.Close();
                //根据住院号将病人的检验信息检索出来，写进datagridview中
                sqlyuj1 = "select testno as 申请号,sqxmdh as 申请项目代号,sqxmmc as 申请项目名称,itemname as 检查项目名称,yblx as 样本类型,cytime as 采样时间 from pt_examination_info ";
                sqlyuj2 = " where case_id in (select case_id from pt_patient_info where case_id='" + row1 + "')";
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);
                if (biao.Rows.Count == 0)
                {//如果没有检验信息，就不显示
                    panel30.Visible = false;
                    //Point a = new Point();
                    //a.X = panel31.Location.X;
                    //a.Y = panel31.Location.Y - panel30.Location.Y;
                    //panel31.Location = a;
                    //a.X = panel25.Location.X;
                    //a.Y = panel25.Location.Y - panel30.Location.Y;
                    //panel25.Location = a;
                    //a.X = panel39.Location.X;
                    //a.Y = panel39.Location.Y - panel30.Location.Y;
                    //panel39.Location = a;
                }
                else
                {
                    panel30.Enabled = true;
                    dataGridView17.DataSource = biao;
                }

                //根据住院号将病人的医嘱信息检索出来，写进datagridview中
                sqlyuj1 = "select order_sub_no  as 组号,case when repeat_indicator=1 then '临时' when repeat_indicator=0 then '长期' end as 长临,order_text as 药品名称,drug_form as 剂型,drug_spec as 规格,route_name as 给药途径,dose as '量/次',dose_units as 用量单位,frequency as '次/日',start_date_time as 开嘱时间,end_date_time as 停嘱时间,skintestresult as 皮试结果,doctor_name as 医生,dept_name as 科室 from pt_orders ";
                sqlyuj2 = " where case_id ='" + row1 + "' order by order_sub_no,order_class ";
                biao = Connect.dubiao(zifuc, sqlyuj1, sqlyuj2);

                dataGridView16.DataSource = biao;
                //将评价的状态写入界面
                Label[] label1 = new Label[3] { label415, pingjiajg4, label416 };
                RadioButton[] radiobutton1 = new RadioButton[2] { radioButton32, radioButton31 };
                zhiliaoyongyaofp ft = new zhiliaoyongyaofp();
                ft.Therapeuticusepj(SQL.constr, zhuangtai, label1, radiobutton1, row1, dny, textBox11);
                //判断tabpage是否已存在，如不存在，新添加进去
                publicclass pub1 = new publicclass();
                pub1.tabpageadd(tabControl5, tabPage19);
            }
        }

        private void button44_Click(object sender, EventArgs e)
        {
            panel25.Enabled = true;
        }

        private void button43_Click(object sender, EventArgs e)
        {
            string row1 = ht;
            using (SqlConnection sql = new SqlConnection(zifuc))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = "select user_name,time,i_level,c_question from zl_main where case_id = '" + row1 + "'";
                if (one.ExecuteScalar() != null)
                {
                    zhuangtai = 1;
                }
                else { zhuangtai = 0; }
                if (zhuangtai == 1)
                {
                    one.CommandText = "delete from zl_main where case_id ='" + row1 + "'";
                    one.ExecuteScalar();
                    one.CommandText = "delete from zl_detail where case_id ='" + row1 + "'";
                    one.ExecuteScalar();
                }
                int i = 0;
                string ss = " ";
                if (radioButton31.Checked)
                {
                    i = 0;
                    ss = "合理";
                }
                else if (radioButton32.Checked)
                {
                    i = 1;
                    ss = "不合理";
                }
                string s;
                one.CommandText = "INSERT INTO zl_main(case_id,user_id,user_name,time,i_level,c_level,c_question) VALUES('" + row1.Trim() + "'," + 1 + ",'" + "管理员" + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "'," + i.ToString() + ",'" + ss.Trim().ToString() + "','" + textBox11.Text.Trim().ToString() + "')";

                one.ExecuteScalar();
                foreach (CheckBox d in dny)
                {
                    if (d.Checked)
                    {
                        s = d.Name.ToString().Replace("pingjia", "");
                        one.CommandText = "insert into zl_detail(case_id,evl_id,evl_desc)values('" + row1.ToString() + "','" + s + "','" + d.Text.ToString() + "')";
                        one.ExecuteScalar();
                    }
                }
            }
            panel25.Enabled = false;
        }

        private void radioButton21_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton21.Enabled)
            {
                panel32.Enabled = false;
                panel19.Enabled = true;
            }
        }

        private void radioButton34_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton34.Checked)
            {
                panel19.Enabled = false;
                panel32.Enabled = true;
            }
        }

        private void button39_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("科室", "  筛选", radioButton23.Checked, "");
            ldo.ShowDialog();
            keshi = zuihoushuju;
            if (keshi != "" || keshi != null)
                keshi = keshi.Substring(0, keshi.Length - 1);
            richTextBox22.Text = keshi;
            zuihoushuju = "  ";
        }

        private void button38_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("医生", "  筛选", false, richTextBox22.Text);
            ldo.ShowDialog();
            yisheng = zuihoushuju;
            if (yisheng != "" || yisheng != null)
                yisheng = yisheng.Substring(0, yisheng.Length - 1);
            richTextBox21.Text = yisheng;
            zuihoushuju = "  ";
        }

        private void button37_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("诊断", "  筛选", false, "");
            ldo.ShowDialog();
            zhenduan = zuihoushuju;
            if (zhenduan != "" || zhenduan != null)
                zhenduan = zhenduan.Substring(0, zhenduan.Length - 1);
            richTextBox20.Text = zhenduan;
            zuihoushuju = "  ";
        }

        private void button36_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("药品", "  筛选", false, "");
            ldo.ShowDialog();
            yaopin = zuihoushuju;
            if (yaopin != "" || yaopin != null)
                yaopin = yaopin.Substring(0, yaopin.Length - 1);
            richTextBox19.Text = yaopin;
            zuihoushuju = "  ";
        }

        private void linkLabel32_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox22.Text = "";
            keshi = "";
        }

        private void linkLabel31_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox21.Text = "";
            yisheng = "";
        }

        private void linkLabel30_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox20.Text = "";
            zhenduan = "";
        }

        private void linkLabel29_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            richTextBox19.Text = "";
            yaopin = "";
        }

        private void radioButton31_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton31.Checked == true)
            {
                panel37.Enabled = false;
                panel35.Enabled = false;
                panel26.Enabled = false;
                panel27.Enabled = false;
            }
        }

        private void radioButton32_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton32.Checked == true)
            {
                panel37.Enabled = true;
                panel35.Enabled = true;
                panel26.Enabled = true;
                panel27.Enabled = true;
            }
        }

        //围术期模块
        //查询条件/查看点评结果选择
        public int dpp;
        //设置抽样条件
        private void radioButton7_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton7.Checked)
            {
                panel14.Enabled = true;
                panel15.Enabled = false;
            }
        }
        //查看点评结果
        private void radioButton10_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton10.Checked)
            {
                panel15.Enabled = true;
                panel14.Enabled = false;
            }
        }
        //选择科室
        private void button19_Click(object sender, EventArgs e)
        {
            //Form keshi = new KeShiZiDian();
            //keshi.ShowDialog();
            Form ldo = new Form2("科室", "  筛选", false, "");
            ldo.ShowDialog();
            keshi = zuihoushuju;
            if (keshi == "" || keshi == null) { }
            else { keshi = keshi.Substring(0, keshi.Length - 1); }
            richTextBox27.Text = keshi;
            zuihoushuju = "  ";
        }
        //选择手术
        private void button18_Click(object sender, EventArgs e)
        {
            Form ldo = new Form2("手术名称", "  筛选", false, "");
            ldo.ShowDialog();
            shumshouingcheng = zuihoushuju;
            if (shumshouingcheng == "" || shumshouingcheng == null) { }
            else { shumshouingcheng = shumshouingcheng.Substring(0, shumshouingcheng.Length - 1); }
            richTextBox26.Text = shumshouingcheng;
            zuihoushuju = "  ";
        }
        //病人科室清空
        private void linkLabel25_Click(object sender, EventArgs e)
        {
            richTextBox27.Text = "";
        }
        //手术名称清空
        private void linkLabel24_Click(object sender, EventArgs e)
        {
            richTextBox26.Text = "";
        }
        //选择点评人
        private void button16_Click(object sender, EventArgs e)
        {
            Form choseuser = new dian_ping_ren();
            choseuser.ShowDialog();
            if (yonghu != "")
            {
                yonghu = yonghu.Remove(yonghu.LastIndexOf(","), 1);
            }
            richTextBox14.Text = yonghu;
            yonghu = "";
        }
        //立即查询
        private void button17_Click(object sender, EventArgs e)
        {
            //publicclass th = new publicclass();
            //th.tabpageadd(tabControl9, tabPage16);
            this.TabControl9.SelectedIndex = 1;
            string cmdText = "";
            //radioButton7是抽样条件
            if (radioButton7.Checked)
            {
                //richTextBox24是抽样份数
                if (richTextBox24.Text != "")
                {
                    cmdText = "Select distinct top " + richTextBox24.Text;
                }
                else
                {
                    cmdText = "select distinct ";
                }
                cmdText = cmdText + " a.case_id,a.inp_no,a.patient_name,a.dept_name,a.doctor_name,a.start_date,a.end_date,a.diagnosis,a.diagnosis2,";
                cmdText = cmdText + " b.peration_name,case b.type when '1' then 'Ⅰ类' when '2' then 'Ⅱ类' when '3' then 'Ⅲ类' when '4' then 'Ⅳ类' else '' end,";
                cmdText = cmdText + " c.user_name,c.time,c_level from pt_patient_info a(nolock)";
                cmdText = cmdText + " left join pt_operation_info b(nolock) on a.case_id=b.case_id left join dpp_main c(nolock) on a.case_id=c.case_id";
                cmdText = cmdText + " where a.case_id  in (select case_id from pt_operation_info) and a.case_id not in (select case_id from dpp_main)";
                cmdText = cmdText + " and a.end_date between '" + dateTimePicker22.Text + "' and '" + dateTimePicker24.Text + "'";
                //richTextBox27是病人科室
                if (richTextBox27.Text != "")
                {
                    string dept_name = Connect.addyh(Connect.yy(richTextBox27.Text.Trim(), any));
                    cmdText = cmdText + " and a.dept_name in (" + dept_name + ")";
                }
                //richTextBox26是手术名称
                if (richTextBox26.Text != "")
                {
                    string peration_name = Connect.addyh(Connect.yy(richTextBox26.Text.Trim(), any));
                    cmdText = cmdText + " and b.peration_name in(" + peration_name + ")";
                }
                if (radioButton9.Checked)//非感染疾病
                {
                    cmdText = cmdText + " and a.diagnosis in (select icd_name from dict_icd where i_gr='0')";
                    cmdText = cmdText + " and a.diagnosis2 in (select icd_name from dict_icd where i_gr='0')";
                }

            }
            //选择查看点评结果
            if (radioButton10.Checked)
            {
                cmdText = "select distinct a.case_id,a.inp_no,a.patient_name,a.dept_name,a.doctor_name,a.start_date,a.end_date,a.diagnosis,a.diagnosis2,";
                cmdText = cmdText + " b.peration_name,case b.type when '1' then 'Ⅰ类' when '2' then 'Ⅱ类' when '3' then 'Ⅲ类' when '4' then 'Ⅳ类' else '' end,";
                cmdText = cmdText + " c.user_name,c.time,c.c_level from pt_patient_info a(nolock)";
                cmdText = cmdText + " left join pt_operation_info b(nolock) on a.case_id=b.case_id left join dpp_main c(nolock) on a.case_id=c.case_id";
                cmdText = cmdText + " where a.case_id  in (select case_id from pt_operation_info) and a.case_id  in (select case_id from dpp_main)";
                cmdText = cmdText + " and c.time between '" + dateTimePicker23.Text + "' and '" + dateTimePicker21.Text + "'";
                if (radioButton12.Checked)
                {
                    cmdText = cmdText + " and c.i_level='0'";
                }
                //dpp_main表中的i_level字典，值为0是合理,值为1是不合理
                if (radioButton11.Checked)
                {
                    cmdText = cmdText + " and c.i_level='1'";
                }
                if (richTextBox14.Text != "")
                {
                    string user_name = Connect.addyh(Connect.yy(richTextBox14.Text.Trim(), any));
                    cmdText = cmdText + " and c.user_name in (" + user_name + ")";
                }
            }
            SqlConnection con1 = new SqlConnection(SQL.constr);
            con1.Open();
            SqlDataAdapter da = new SqlDataAdapter(cmdText, con1);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataGridView7.Rows.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dataGridView7.Rows.Add();
                dataGridView7.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString();
                dataGridView7.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString();
                dataGridView7.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString();
                dataGridView7.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString();
                dataGridView7.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString();
                dataGridView7.Rows[i].Cells[5].Value = dt.Rows[i][5].ToString();
                dataGridView7.Rows[i].Cells[6].Value = dt.Rows[i][6].ToString();
                dataGridView7.Rows[i].Cells[7].Value = dt.Rows[i][7].ToString();
                dataGridView7.Rows[i].Cells[8].Value = dt.Rows[i][8].ToString();
                dataGridView7.Rows[i].Cells[9].Value = dt.Rows[i][9].ToString();
                dataGridView7.Rows[i].Cells[10].Value = dt.Rows[i][10].ToString();
                dataGridView7.Rows[i].Cells[11].Value = dt.Rows[i][11].ToString();
                dataGridView7.Rows[i].Cells[12].Value = dt.Rows[i][12].ToString();
                dataGridView7.Rows[i].Cells[13].Value = dt.Rows[i][13].ToString();
            }
            //dataGridView7是zlc查询结果清单
        }
        //zlc医嘱明细中的病人基本信息
        private void dpp_patient_info()
        {
            
            string myID;
            myID = dataGridView7.Rows[dpp].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            string strsql = "select inp_no , patient_name,sex,birth_date,age,body_height,body_weight,idnum,nation,birthplace,workplace,linkplace,linktel,start_date,end_date,dept_name,bed_no,doctor_name,diagnosis,diagnosis2,allergen,nurse_class,pay_class from pt_patient_info  where  case_id='" + myID + "' and case_id like 'Zy%'";
            SqlConnection conn = new SqlConnection(SQL.constr);
            conn.Open();
            SqlDataAdapter hhh = new SqlDataAdapter(strsql, SQL.constr);
            DataSet dtt = new DataSet();
            hhh.Fill(dtt);
            for (int i = 0; i < dtt.Tables[0].Rows.Count; i++)
            {
                label175.Text = dtt.Tables[0].Rows[i].ItemArray[0].ToString();//住院号
                label204.Text = dtt.Tables[0].Rows[i].ItemArray[1].ToString();//病人名
                label202.Text = dtt.Tables[0].Rows[i].ItemArray[2].ToString();//性别
                label200.Text = dtt.Tables[0].Rows[i].ItemArray[3].ToString();//出生日期
                label198.Text = dtt.Tables[0].Rows[i].ItemArray[4].ToString();//年龄
                label196.Text = dtt.Tables[0].Rows[i].ItemArray[5].ToString();//身高
                label194.Text = dtt.Tables[0].Rows[i].ItemArray[6].ToString();//体重
                label192.Text = dtt.Tables[0].Rows[i].ItemArray[7].ToString();//身份证
                label190.Text = dtt.Tables[0].Rows[i].ItemArray[8].ToString();//民族
                label187.Text = dtt.Tables[0].Rows[i].ItemArray[9].ToString();//籍贯
                label183.Text = dtt.Tables[0].Rows[i].ItemArray[10].ToString();//工作单位
                label188.Text = dtt.Tables[0].Rows[i].ItemArray[11].ToString();//联系地址
                label178.Text = dtt.Tables[0].Rows[i].ItemArray[12].ToString();//联系电话
                label184.Text = dtt.Tables[0].Rows[i].ItemArray[13].ToString();//入院日期
                label185.Text = dtt.Tables[0].Rows[i].ItemArray[14].ToString();//出院日期
                label182.Text = dtt.Tables[0].Rows[i].ItemArray[15].ToString();//科室
                label181.Text = dtt.Tables[0].Rows[i].ItemArray[16].ToString();//床号
                label179.Text = dtt.Tables[0].Rows[i].ItemArray[17].ToString();//医生
                label180.Text = dtt.Tables[0].Rows[i].ItemArray[18].ToString();//入院诊断
                label172.Text = dtt.Tables[0].Rows[i].ItemArray[19].ToString();//出院诊断
                label176.Text = dtt.Tables[0].Rows[i].ItemArray[20].ToString();//过敏历
                label177.Text = dtt.Tables[0].Rows[i].ItemArray[21].ToString();//护理级别
                label173.Text = dtt.Tables[0].Rows[i].ItemArray[22].ToString();//费用类别
            }
            conn.Close();


            //医嘱内容
            string case_idi;
            case_idi = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            string strsql10001;
            strsql10001 = "exec [Get_pt_orders]'" + case_idi + "','Zy'";
            //string strsql10001;
            // strsql10001 = "select case when b.order_class=1 then '临'  when b.order_class=3 then '长'  end as 长临,b.order_text ,b.drug_form , b.drug_spec  ,b.route_name ,  b.dose , b.dose_units ,b.num  ,b.num_units ,b.start_date_time ,b.end_date_time ,b.skintestresult , b.doctor_name ,b.dept_name from pt_patient_info a ,pt_orders b where a.case_id=b.case_id and  a.case_id='" + myID + "'";
            SqlConnection conn2 = new SqlConnection(SQL.constr);
            conn2.Open();
            SqlDataAdapter dh1 = new SqlDataAdapter(strsql10001, SQL.constr);
            DataTable dt2 = new DataTable();
            dh1.Fill(dt2);
            dataGridView9.Rows.Clear();
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                dataGridView9.Rows.Add();
                dataGridView9.Rows[i].Cells[0].Value = dt2.Rows[i][0].ToString();//组
                dataGridView9.Rows[i].Cells[1].Value = dt2.Rows[i][1].ToString();//长临
                dataGridView9.Rows[i].Cells[2].Value = dt2.Rows[i][2].ToString();//基
                dataGridView9.Rows[i].Cells[3].Value = dt2.Rows[i][3].ToString();//抗
                dataGridView9.Rows[i].Cells[4].Value = dt2.Rows[i][4].ToString();//兴
                dataGridView9.Rows[i].Cells[5].Value = dt2.Rows[i][5].ToString();//特
                dataGridView9.Rows[i].Cells[6].Value = dt2.Rows[i][6].ToString();//药品
                dataGridView9.Rows[i].Cells[7].Value = dt2.Rows[i][7].ToString();//剂型
                dataGridView9.Rows[i].Cells[8].Value = dt2.Rows[i][8].ToString();//规格
                dataGridView9.Rows[i].Cells[9].Value = dt2.Rows[i][9].ToString();//给药途径
                dataGridView9.Rows[i].Cells[10].Value = dt2.Rows[i][10].ToString();//量次
                dataGridView9.Rows[i].Cells[11].Value = dt2.Rows[i][11].ToString();//给药单位
                //dataGridView12.Rows[i].Cells[12].Value = dt2.Rows[i][12].ToString();//
                //dataGridView12.Rows[i].Cells[13].Value = dt2.Rows[i][13].ToString();//
                dataGridView9.Rows[i].Cells[14].Value = dt2.Rows[i][12].ToString();//开嘱时间
                dataGridView9.Rows[i].Cells[15].Value = dt2.Rows[i][13].ToString();//停嘱时间
                dataGridView9.Rows[i].Cells[16].Value = dt2.Rows[i][14].ToString();//目的
                dataGridView9.Rows[i].Cells[17].Value = dt2.Rows[i][15].ToString();//皮实结果
                dataGridView9.Rows[i].Cells[18].Value = dt2.Rows[i][16].ToString();//开嘱医生
                dataGridView9.Rows[i].Cells[19].Value = dt2.Rows[i][17].ToString();//执行科室
                //dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][14].ToString();//

            }
            conn2.Close();

            //检验详细
            string strsql0106;
            strsql0106 = "select distinct b.testno as 申请号, b.sqxmdh as 申请项目代码, b.sqxmmc as 申请项目名称, b.yblx as 样本类型 , b.cytime as 采样时间 from pt_patient_info a ,pt_examination_info b where a.case_id=b.case_id and  a.case_id='" + myID + "'";
            // }
            SqlConnection conn7 = new SqlConnection(SQL.constr);
            conn7.Open();
            SqlDataAdapter dh = new SqlDataAdapter(strsql0106, SQL.constr);
            DataTable dt7 = new DataTable();
            dh.Fill(dt7);
            dataGridView8.Rows.Clear();
            for (int i = 0; i < dt7.Rows.Count; i++)
            {
                dataGridView8.Rows.Add();
                dataGridView8.Rows[i].Cells[0].Value = dt7.Rows[i][0].ToString();
                dataGridView8.Rows[i].Cells[1].Value = dt7.Rows[i][1].ToString();
                dataGridView8.Rows[i].Cells[2].Value = dt7.Rows[i][2].ToString();
                dataGridView8.Rows[i].Cells[3].Value = dt7.Rows[i][3].ToString();
                dataGridView8.Rows[i].Cells[4].Value = dt7.Rows[i][4].ToString();

            }
            conn7.Close();


            //手术情况
            string strsql110;
            strsql110 = "select distinct  a.peration_name , a.start_date , a.end_date , b.type, a.shuqian_time ,a.shuzhong,a.shuhou from pt_operation_info a ,pt_opr_incision_info b where a.case_id=b.case_id  and  a.case_id='" + myID + "'";
            SqlConnection conn110 = new SqlConnection(SQL.constr);
            conn110.Open();
            SqlDataAdapter dh110 = new SqlDataAdapter(strsql110, SQL.constr);
            DataTable dt110 = new DataTable();
            dh110.Fill(dt110);
            dataGridView10.Rows.Clear();
            for (int i = 0; i < dt110.Rows.Count; i++)
            {
                dataGridView10.Rows.Add();
                dataGridView10.Rows[i].Cells[0].Value = dt110.Rows[i][0].ToString();
                dataGridView10.Rows[i].Cells[1].Value = dt110.Rows[i][1].ToString();
                dataGridView10.Rows[i].Cells[2].Value = dt110.Rows[i][2].ToString();
                dataGridView10.Rows[i].Cells[3].Value = dt110.Rows[i][3].ToString();
                dataGridView10.Rows[i].Cells[4].Value = dt110.Rows[i][4].ToString();
                dataGridView10.Rows[i].Cells[5].Value = dt110.Rows[i][5].ToString();
                dataGridView10.Rows[i].Cells[6].Value = dt110.Rows[i][6].ToString();

            }
            conn110.Close();

        }
        //双击病人列表，显示病人基本信息
        private void dataGridView7_DoubleClick(object sender, EventArgs e)
        {

            //病人基本信息
            //publicclass th = new publicclass();
            //th.tabpageadd(tabControl9, tabPage14);
            this.TabControl9.SelectedIndex = 2;
            dpp = dataGridView7.CurrentRow.Index;
            dpp_patient_info();//显示病人基本信息的方法，直接转到定义
            dpp_dp_info();//显示病人点评信息的方法，直接转到定义

        }
        //zlc双击检验情况，显示检验结果
        private void dataGridView8_DoubleClick(object sender, EventArgs e)
        {
            DangQianHang.aa = dataGridView8.Rows[dataGridView8.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = dataGridView8.Rows[dataGridView8.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();//转到定义处
            jianyanxiagnxi.ShowDialog();
        }

        //显示病人点评信息
        private void dpp_dp_info()
        {
            string dpp_allid = ",";
            richTextBox13.Text = "";
            checkBox19.Checked = false; checkBox21.Checked = false; checkBox23.Checked = false; checkBox30.Checked = false; checkBox51.Checked = false;
            checkBox21.Checked = false; checkBox24.Checked = false; checkBox26.Checked = false; checkBox29.Checked = false; checkBox33.Checked = false;
            checkBox34.Checked = false; checkBox35.Checked = false; checkBox36.Checked = false; checkBox37.Checked = false; checkBox38.Checked = false;
            checkBox39.Checked = false; checkBox40.Checked = false; checkBox41.Checked = false; checkBox42.Checked = false; checkBox46.Checked = false;
            checkBox47.Checked = false; checkBox48.Checked = false; checkBox49.Checked = false; checkBox43.Checked = false; checkBox44.Checked = false;
            string myID;
            dpp_allid = ",";
            myID = dataGridView7.Rows[dpp].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            SqlConnection con1 = new SqlConnection(SQL.constr);
            SqlConnection con2 = new SqlConnection(SQL.constr);
            con1.Open();
            con2.Open();
            string cmdText1 = "select  dpp_id from dpp_detail where  case_id='" + myID + "'";
            string cmdText2 = "select c_question from dpp_main where case_id='" + myID + "'";
            SqlCommand cmd1 = new SqlCommand(cmdText1, con1);
            SqlCommand cmd2 = new SqlCommand(cmdText2, con2);
            SqlDataReader dr1 = cmd1.ExecuteReader();
            SqlDataReader dr2 = cmd2.ExecuteReader();
            while (dr2.Read())
            {
                richTextBox13.Text = dr2[0].ToString();
            }
            while (dr1.Read())
            {
                dpp_allid = dpp_allid + dr1[0].ToString();
                dpp_allid = dpp_allid + ",";
            }
            dr2.Close();
            dr1.Close();
            con1.Close();
            con2.Close();
            if (dpp_allid.IndexOf(",1,") >= 0) { checkBox19.Checked = true; }
            if (dpp_allid.IndexOf(",2,") >= 0) { checkBox21.Checked = true; }
            if (dpp_allid.IndexOf(",3,") >= 0) { checkBox23.Checked = true; }
            if (dpp_allid.IndexOf(",5,") >= 0) { checkBox30.Checked = true; }
            if (dpp_allid.IndexOf(",6,") >= 0) { checkBox51.Checked = true; }
            if (dpp_allid.IndexOf(",7,") >= 0) { checkBox21.Checked = true; }
            if (dpp_allid.IndexOf(",8,") >= 0) { checkBox24.Checked = true; }
            if (dpp_allid.IndexOf(",9,") >= 0) { checkBox26.Checked = true; }
            if (dpp_allid.IndexOf(",10,") >= 0) { checkBox29.Checked = true; }
            if (dpp_allid.IndexOf(",11,") >= 0) { checkBox33.Checked = true; }
            if (dpp_allid.IndexOf(",12,") >= 0) { checkBox34.Checked = true; }
            if (dpp_allid.IndexOf(",13,") >= 0) { checkBox35.Checked = true; }
            if (dpp_allid.IndexOf(",14,") >= 0) { checkBox36.Checked = true; }
            if (dpp_allid.IndexOf(",17,") >= 0) { checkBox37.Checked = true; }
            if (dpp_allid.IndexOf(",18,") >= 0) { checkBox38.Checked = true; }
            if (dpp_allid.IndexOf(",19,") >= 0) { checkBox39.Checked = true; }
            if (dpp_allid.IndexOf(",20,") >= 0) { checkBox40.Checked = true; }
            if (dpp_allid.IndexOf(",21,") >= 0) { checkBox41.Checked = true; }
            if (dpp_allid.IndexOf(",22,") >= 0) { checkBox42.Checked = true; }
            if (dpp_allid.IndexOf(",23,") >= 0) { checkBox46.Checked = true; }
            if (dpp_allid.IndexOf(",24,") >= 0) { checkBox47.Checked = true; }
            if (dpp_allid.IndexOf(",25,") >= 0) { checkBox48.Checked = true; }
            if (dpp_allid.IndexOf(",26,") >= 0) { checkBox49.Checked = true; }
            if (dpp_allid.IndexOf(",27,") >= 0) { checkBox43.Checked = true; }
            if (dpp_allid.IndexOf(",44,") >= 0) { checkBox44.Checked = true; }
            label224.Text = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[11].Value.ToString();
            label226.Text = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[12].Value.ToString();
            label222.Text = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[13].Value.ToString();
            if (dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[13].Value.ToString() != "不合理")
            {
                radioButton5.Checked = true;
                panel10.Enabled = false;
            }
            else if (dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[13].Value.ToString() == "不合理")
            {
                radioButton6.Checked = true;
                panel10.Enabled = true;
            }

        }
        #region 保存点评详细信息
        private void insertdppdetail()
        {
            string case_id;
            case_id = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            SqlConnection con2 = new SqlConnection(SQL.constr);
            con2.Open();
            if (checkBox19.Checked)
            {
                string cmdText1 = "insert into dpp_detail values('" + case_id + "','1','" + checkBox19.Text + "')";
                SqlCommand cmd1 = new SqlCommand(cmdText1, con2);
                cmd1.ExecuteNonQuery();
            }
            if (checkBox21.Checked)
            {
                string cmdText2 = "insert into dpp_detail values('" + case_id + "','2','" + checkBox21.Text + "')";
                SqlCommand cmd2 = new SqlCommand(cmdText2, con2);
                cmd2.ExecuteNonQuery();
            }
            if (checkBox23.Checked)
            {
                string cmdText3 = "insert into dpp_detail values('" + case_id + "','3','" + checkBox23.Text + "')";
                SqlCommand cmd3 = new SqlCommand(cmdText3, con2);
                cmd3.ExecuteNonQuery();
            }
            if (checkBox30.Checked)
            {
                string cmdText4 = "insert into dpp_detail values('" + case_id + "','5','" + checkBox30.Text + "')";
                SqlCommand cmd4 = new SqlCommand(cmdText4, con2);
                cmd4.ExecuteNonQuery();
            }
            if (checkBox51.Checked)
            {
                string cmdText5 = "insert into dpp_detail values('" + case_id + "','6','" + checkBox51.Text + "')";
                SqlCommand cmd5 = new SqlCommand(cmdText5, con2);
                cmd5.ExecuteNonQuery();
            }
            if (checkBox22.Checked)
            {
                string cmdText6 = "insert into dpp_detail values('" + case_id + "','7','" + checkBox22.Text + "')";
                SqlCommand cmd6 = new SqlCommand(cmdText6, con2);
                cmd6.ExecuteNonQuery();
            }
            if (checkBox24.Checked)
            {
                string cmdText7 = "insert into dpp_detail values('" + case_id + "','8','" + checkBox24.Text + "')";
                SqlCommand cmd7 = new SqlCommand(cmdText7, con2);
                cmd7.ExecuteNonQuery();
            }
            if (checkBox26.Checked)
            {
                string cmdText8 = "insert into dpp_detail values('" + case_id + "','9','" + checkBox26.Text + "')";
                SqlCommand cmd8 = new SqlCommand(cmdText8, con2);
                cmd8.ExecuteNonQuery();
            }
            if (checkBox29.Checked)
            {
                string cmdText9 = "insert into dpp_detail values('" + case_id + "','10','" + checkBox29.Text + "')";
                SqlCommand cmd9 = new SqlCommand(cmdText9, con2);
                cmd9.ExecuteNonQuery();
            }
            if (checkBox33.Checked)
            {
                string cmdText10 = "insert into dpp_detail values('" + case_id + "','11','" + checkBox33.Text + "')";
                SqlCommand cmd10 = new SqlCommand(cmdText10, con2);
                cmd10.ExecuteNonQuery();
            }
            if (checkBox34.Checked)
            {
                string cmdText11 = "insert into dpp_detail values('" + case_id + "','12','" + checkBox34.Text + "')";
                SqlCommand cmd11 = new SqlCommand(cmdText11, con2);
                cmd11.ExecuteNonQuery();
            }
            if (checkBox35.Checked)
            {
                string cmdText12 = "insert into dpp_detail values('" + case_id + "','13','" + checkBox35.Text + "')";
                SqlCommand cmd12 = new SqlCommand(cmdText12, con2);
                cmd12.ExecuteNonQuery();
            }
            if (checkBox36.Checked)
            {
                string cmdText13 = "insert into dpp_detail values('" + case_id + "','14','" + checkBox36.Text + "')";
                SqlCommand cmd13 = new SqlCommand(cmdText13, con2);
                cmd13.ExecuteNonQuery();
            }
            if (checkBox37.Checked)
            {
                string cmdText14 = "insert into dpp_detail values('" + case_id + "','17','" + checkBox37.Text + "')";
                SqlCommand cmd14 = new SqlCommand(cmdText14, con2);
                cmd14.ExecuteNonQuery();
            }
            if (checkBox38.Checked)
            {
                string cmdText15 = "insert into dpp_detail values('" + case_id + "','18','" + checkBox38.Text + "')";
                SqlCommand cmd15 = new SqlCommand(cmdText15, con2);
                cmd15.ExecuteNonQuery();
            }
            if (checkBox39.Checked)
            {
                string cmdText16 = "insert into dpp_detail values('" + case_id + "','19','" + checkBox39.Text + "')";
                SqlCommand cmd16 = new SqlCommand(cmdText16, con2);
                cmd16.ExecuteNonQuery();
            }
            if (checkBox40.Checked)
            {
                string cmdText17 = "insert into dpp_detail values('" + case_id + "','20','" + checkBox40.Text + "')";
                SqlCommand cmd17 = new SqlCommand(cmdText17, con2);
                cmd17.ExecuteNonQuery();
            }
            if (checkBox41.Checked)
            {
                string cmdText18 = "insert into dpp_detail values('" + case_id + "','21','" + checkBox41.Text + "')";
                SqlCommand cmd18 = new SqlCommand(cmdText18, con2);
                cmd18.ExecuteNonQuery();
            }
            if (checkBox42.Checked)
            {
                string cmdText19 = "insert into dpp_detail values('" + case_id + "','22','" + checkBox42.Text + "')";
                SqlCommand cmd19 = new SqlCommand(cmdText19, con2);
                cmd19.ExecuteNonQuery();
            }
            if (checkBox46.Checked)
            {
                string cmdText20 = "insert into dpp_detail values('" + case_id + "','23','" + checkBox46.Text + "')";
                SqlCommand cmd20 = new SqlCommand(cmdText20, con2);
                cmd20.ExecuteNonQuery();
            }
            if (checkBox47.Checked)
            {
                string cmdText21 = "insert into dpp_detail values('" + case_id + "','24','" + checkBox47.Text + "')";
                SqlCommand cmd21 = new SqlCommand(cmdText21, con2);
                cmd21.ExecuteNonQuery();
            }
            if (checkBox48.Checked)
            {
                string cmdText22 = "insert into dpp_detail values('" + case_id + "','25','" + checkBox48.Text + "')";
                SqlCommand cmd22 = new SqlCommand(cmdText22, con2);
                cmd22.ExecuteNonQuery();
            }
            if (checkBox49.Checked)
            {
                string cmdText23 = "insert into dpp_detail values('" + case_id + "','26','" + checkBox49.Text + "')";
                SqlCommand cmd23 = new SqlCommand(cmdText23, con2);
                cmd23.ExecuteNonQuery();
            }
            if (checkBox43.Checked)
            {
                string cmdText24 = "insert into dpp_detail values('" + case_id + "','27','" + checkBox43.Text + "')";
                SqlCommand cmd24 = new SqlCommand(cmdText24, con2);
                cmd24.ExecuteNonQuery();
            }
            if (checkBox44.Checked)
            {
                string cmdText25 = "insert into dpp_detail values('" + case_id + "','28','" + checkBox44.Text + "')";
                SqlCommand cmd25 = new SqlCommand(cmdText25, con2);
                cmd25.ExecuteNonQuery();
            }
            con2.Close();
            //MessageBox.Show("保存点评信息成功。", "系统提示");
        }
        #endregion

        //保存评价
        private void button20_Click(object sender, EventArgs e)
        {
            string case_id;
            case_id = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            SqlConnection con1 = new SqlConnection(SQL.constr);
            con1.Open();
            string cmdText1 = "delete from dpp_main where case_id='" + case_id + "'";
            SqlCommand cmd1 = new SqlCommand(cmdText1, con1);
            cmd1.ExecuteNonQuery();
            string cmdText2 = "delete from dpp_detail where case_id='" + case_id + "'";
            SqlCommand cmd2 = new SqlCommand(cmdText2, con1);
            cmd2.ExecuteNonQuery();
            string dpp_desc = richTextBox13.Text;
            string cmdText3 = "";
            if (radioButton5.Checked)
            {
                cmdText3 = "insert into dpp_main values('" + case_id + "','"+name1+"','"+name2+"',convert(varchar(10),getdate(),121),'0','合理',NULL)";
                SqlCommand cmd3 = new SqlCommand(cmdText3, con1);
                cmd3.ExecuteNonQuery();
                label222.Text = "合理";
                dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[13].Value = "合理";
            }
            else if (radioButton6.Checked)
            {
                cmdText3 = "insert into dpp_main values('" + case_id + "','" + name1 + "','" + name2 + "',convert(varchar(10),getdate(),121),'1','不合理','" + dpp_desc + "')";
                SqlCommand cmd3 = new SqlCommand(cmdText3, con1);
                cmd3.ExecuteNonQuery();
                label222.Text = "不合理";
                dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[13].Value = "不合理";
                insertdppdetail();
            }
            con1.Close();
            label224.Text = name2;
            label226.Text = System.DateTime.Now.ToShortDateString().ToString();
            dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[11].Value = name2;
            dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[12].Value = System.DateTime.Now.ToShortDateString().ToString();
            panel10.Enabled = false;
        }
        //重新评价
        private void button21_Click(object sender, EventArgs e)
        {
            dpp = dataGridView7.CurrentRow.Index;
            dpp_dp_info();
        }
        //上例
        private void button22_Click(object sender, EventArgs e)
        {
            dpp = dataGridView7.CurrentRow.Index;
            dataGridView7.Rows[dpp].Selected = false;
            if (dpp > 0)
            {
                dataGridView7.CurrentCell = dataGridView7.Rows[dpp - 1].Cells[1];
                dpp -= 1;
            }
            else if (dpp == 0)
            {
                dataGridView7.CurrentCell = dataGridView7.Rows[dataGridView7.Rows.Count - 1].Cells[1];
                dpp = dataGridView7.Rows.Count - 1;
            }
            dataGridView7.Rows[dpp].Selected = true;
            dpp_patient_info();
            dpp_dp_info();

        }
        //下例
        private void button23_Click(object sender, EventArgs e)
        {
            dpp = dataGridView7.CurrentRow.Index;
            dataGridView7.Rows[dpp].Selected = false;
            if (dpp < dataGridView7.Rows.Count - 1)
            {
                dataGridView7.CurrentCell = dataGridView7.Rows[dpp + 1].Cells[1];
                dpp += 1;
            }
            else
            {
                dataGridView7.CurrentCell = dataGridView7.Rows[0].Cells[1];
                dpp = 0;
            }
            dataGridView7.Rows[dpp].Selected = true;
            dpp_patient_info();
            dpp_dp_info();
        }

        private void button27_Click(object sender, EventArgs e)
        {
            Form choseuser = new dian_ping_ren();
            choseuser.ShowDialog();
            if (yonghu != "")
            {
                yonghu = yonghu.Remove(yonghu.LastIndexOf(","), 1);
            }
            textBox8.Text = yonghu;
            yonghu = "";
        }

        private void radioButton13_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton13.Checked)
            {
                panel44.Enabled = true;
                panel45.Enabled = false;

            }
        }

        private void radioButton14_CheckedChanged(object sender, EventArgs e)
        {
            panel45.Enabled = true;
            panel44.Enabled = false;
        }

        private void linkLabel16_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //清空
            richTextBox10.Text = "";
        }

        private void linkLabel15_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //清空
            richTextBox9.Text = "";
        }

        private void linkLabel14_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //清空
            richTextBox8.Text = "";
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton4.Checked)
            {
                panel46.Enabled = true;
            }
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton3.Checked)
            {
                panel46.Enabled = false;
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Form choseuser = new dian_ping_ren();
            choseuser.ShowDialog();
            if (yonghu != "")
            {
                yonghu = yonghu.Remove(yonghu.LastIndexOf(","), 1);
            }
            richTextBox12.Text = yonghu;
            yonghu = "";
        }

        private void button14_Click(object sender, EventArgs e)
        {
            richTextBox10.Text = "";
            richTextBox9.Text = "";
            richTextBox8.Text = "";
            richTextBox11.Text = "";
            richTextBox12.Text = "";
            richTextBox7.Text = "";
        }

        private void button9_Click(object sender, EventArgs e)
        {
            xh = xh + 1;
            if (xh > dataGridView1.Rows.Count)
            {
                MessageBox.Show("已经是最后一位病人了。");
                xh -= 1;
                return;
            }
            NewMethod((string)eny[xh]);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            xh -= 1;
            if (xh < 0)
            {
                MessageBox.Show("已经是第一位病人了。");
                xh += 1;
                return;
            }
            NewMethod((string)eny[xh]);
        }


        private void radioButton15_Click(object sender, EventArgs e)
        {
            if (radioButton15.Checked)
            {
                string case_idi;
                case_idi = dataGridView11.Rows[dataGridView11.CurrentRow.Index].Cells[8].Value.ToString().Trim();
                cfz = case_idi;

                string cmdText5 = "exec [Get_pt_orders_kjy]'" + case_idi + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();

                SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                DataTable ds4 = new DataTable();
                da4.Fill(ds4);
                dataGridView12.Rows.Clear();
                for (int i = 0; i < ds4.Rows.Count; i++)
                {
                    dataGridView12.Rows.Add();
                    dataGridView12.Rows[i].Cells[0].Value = ds4.Rows[i][0].ToString();//组
                    dataGridView12.Rows[i].Cells[1].Value = ds4.Rows[i][1].ToString();//长临
                    dataGridView12.Rows[i].Cells[2].Value = ds4.Rows[i][2].ToString();//基
                    dataGridView12.Rows[i].Cells[3].Value = ds4.Rows[i][3].ToString();//抗
                    dataGridView12.Rows[i].Cells[4].Value = ds4.Rows[i][4].ToString();//兴
                    dataGridView12.Rows[i].Cells[5].Value = ds4.Rows[i][5].ToString();//特
                    dataGridView12.Rows[i].Cells[6].Value = ds4.Rows[i][6].ToString();//药品
                    dataGridView12.Rows[i].Cells[7].Value = ds4.Rows[i][7].ToString();//剂型
                    dataGridView12.Rows[i].Cells[8].Value = ds4.Rows[i][8].ToString();//规格
                    dataGridView12.Rows[i].Cells[9].Value = ds4.Rows[i][9].ToString();//给药途径
                    dataGridView12.Rows[i].Cells[10].Value = ds4.Rows[i][10].ToString();//量次
                    dataGridView12.Rows[i].Cells[11].Value = ds4.Rows[i][11].ToString();//给药单位
                    //dataGridView12.Rows[i].Cells[12].Value = dt2.Rows[i][12].ToString();//
                    //dataGridView12.Rows[i].Cells[13].Value = dt2.Rows[i][13].ToString();//
                    dataGridView12.Rows[i].Cells[14].Value = ds4.Rows[i][12].ToString();//开嘱时间
                    dataGridView12.Rows[i].Cells[15].Value = ds4.Rows[i][13].ToString();//停嘱时间
                    dataGridView12.Rows[i].Cells[16].Value = ds4.Rows[i][14].ToString();//目的
                    dataGridView12.Rows[i].Cells[17].Value = ds4.Rows[i][15].ToString();//皮实结果
                    dataGridView12.Rows[i].Cells[18].Value = ds4.Rows[i][16].ToString();//开嘱医生
                    dataGridView12.Rows[i].Cells[19].Value = ds4.Rows[i][17].ToString();//执行科室
                    //dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][14].ToString();//

                }
                //this.evl_cf_list.DataSource = ds4.Tables[0].DefaultView;
                con1.Close();

            }
        }
        //zlc医嘱明细中的处方医嘱中，选择“抗菌药”
        private void radioButton16_Click(object sender, EventArgs e)
        {
            if (radioButton16.Checked)
            {
                string case_idi;
                case_idi = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString().Trim();
                cfz = case_idi;

                string cmdText5 = "exec [Get_pt_orders_kjy]'" + case_idi + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();

                SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                DataTable ds4 = new DataTable();
                da4.Fill(ds4);
                dataGridView9.Rows.Clear();
                for (int i = 0; i < ds4.Rows.Count; i++)
                {
                    dataGridView9.Rows.Add();
                    dataGridView9.Rows[i].Cells[0].Value = ds4.Rows[i][0].ToString();//组
                    dataGridView9.Rows[i].Cells[1].Value = ds4.Rows[i][1].ToString();//长临
                    dataGridView9.Rows[i].Cells[2].Value = ds4.Rows[i][2].ToString();//基
                    dataGridView9.Rows[i].Cells[3].Value = ds4.Rows[i][3].ToString();//抗
                    dataGridView9.Rows[i].Cells[4].Value = ds4.Rows[i][4].ToString();//兴
                    dataGridView9.Rows[i].Cells[5].Value = ds4.Rows[i][5].ToString();//特
                    dataGridView9.Rows[i].Cells[6].Value = ds4.Rows[i][6].ToString();//药品
                    dataGridView9.Rows[i].Cells[7].Value = ds4.Rows[i][7].ToString();//剂型
                    dataGridView9.Rows[i].Cells[8].Value = ds4.Rows[i][8].ToString();//规格
                    dataGridView9.Rows[i].Cells[9].Value = ds4.Rows[i][9].ToString();//给药途径
                    dataGridView9.Rows[i].Cells[10].Value = ds4.Rows[i][10].ToString();//量次
                    dataGridView9.Rows[i].Cells[11].Value = ds4.Rows[i][11].ToString();//给药单位
                    //dataGridView12.Rows[i].Cells[12].Value = dt2.Rows[i][12].ToString();//
                    //dataGridView12.Rows[i].Cells[13].Value = dt2.Rows[i][13].ToString();//
                    dataGridView9.Rows[i].Cells[14].Value = ds4.Rows[i][12].ToString();//开嘱时间
                    dataGridView9.Rows[i].Cells[15].Value = ds4.Rows[i][13].ToString();//停嘱时间
                    dataGridView9.Rows[i].Cells[16].Value = ds4.Rows[i][14].ToString();//目的
                    dataGridView9.Rows[i].Cells[17].Value = ds4.Rows[i][15].ToString();//皮实结果
                    dataGridView9.Rows[i].Cells[18].Value = ds4.Rows[i][16].ToString();//开嘱医生
                    dataGridView9.Rows[i].Cells[19].Value = ds4.Rows[i][17].ToString();//执行科室
                    //dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][14].ToString();//

                }
                //this.evl_cf_list.DataSource = ds4.Tables[0].DefaultView;
                con1.Close();
            }

        }

        private void radioButton17_Click(object sender, EventArgs e)
        {
            get_yizhu1();
        }
        //zlc医嘱明细中的处方医嘱中，选择“全部医嘱”
        private void radioButton18_Click(object sender, EventArgs e)
        {
            //医嘱内容
            string case_idi;
            case_idi = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString().Trim();
            string strsql10001;
            strsql10001 = "exec [Get_pt_orders]'" + case_idi + "','Zy'";
            //string strsql10001;
            // strsql10001 = "select case when b.order_class=1 then '临'  when b.order_class=3 then '长'  end as 长临,b.order_text ,b.drug_form , b.drug_spec  ,b.route_name ,  b.dose , b.dose_units ,b.num  ,b.num_units ,b.start_date_time ,b.end_date_time ,b.skintestresult , b.doctor_name ,b.dept_name from pt_patient_info a ,pt_orders b where a.case_id=b.case_id and  a.case_id='" + myID + "'";
            SqlConnection conn2 = new SqlConnection(SQL.constr);
            conn2.Open();
            SqlDataAdapter dh1 = new SqlDataAdapter(strsql10001, SQL.constr);
            DataTable dt2 = new DataTable();
            dh1.Fill(dt2);
            dataGridView9.Rows.Clear();
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                dataGridView9.Rows.Add();
                dataGridView9.Rows[i].Cells[0].Value = dt2.Rows[i][0].ToString();//组
                dataGridView9.Rows[i].Cells[1].Value = dt2.Rows[i][1].ToString();//长临
                dataGridView9.Rows[i].Cells[2].Value = dt2.Rows[i][2].ToString();//基
                dataGridView9.Rows[i].Cells[3].Value = dt2.Rows[i][3].ToString();//抗
                dataGridView9.Rows[i].Cells[4].Value = dt2.Rows[i][4].ToString();//兴
                dataGridView9.Rows[i].Cells[5].Value = dt2.Rows[i][5].ToString();//特
                dataGridView9.Rows[i].Cells[6].Value = dt2.Rows[i][6].ToString();//药品
                dataGridView9.Rows[i].Cells[7].Value = dt2.Rows[i][7].ToString();//剂型
                dataGridView9.Rows[i].Cells[8].Value = dt2.Rows[i][8].ToString();//规格
                dataGridView9.Rows[i].Cells[9].Value = dt2.Rows[i][9].ToString();//给药途径
                dataGridView9.Rows[i].Cells[10].Value = dt2.Rows[i][10].ToString();//量次
                dataGridView9.Rows[i].Cells[11].Value = dt2.Rows[i][11].ToString();//给药单位
                //dataGridView12.Rows[i].Cells[12].Value = dt2.Rows[i][12].ToString();//
                //dataGridView12.Rows[i].Cells[13].Value = dt2.Rows[i][13].ToString();//
                dataGridView9.Rows[i].Cells[14].Value = dt2.Rows[i][12].ToString();//开嘱时间
                dataGridView9.Rows[i].Cells[15].Value = dt2.Rows[i][13].ToString();//停嘱时间
                dataGridView9.Rows[i].Cells[16].Value = dt2.Rows[i][14].ToString();//目的
                dataGridView9.Rows[i].Cells[17].Value = dt2.Rows[i][15].ToString();//皮实结果
                dataGridView9.Rows[i].Cells[18].Value = dt2.Rows[i][16].ToString();//开嘱医生
                dataGridView9.Rows[i].Cells[19].Value = dt2.Rows[i][17].ToString();//执行科室
                //dataGridView12.Rows[i].Cells[19].Value = dt2.Rows[i][14].ToString();//

            }
            conn2.Close();
        }

        private void button24_Click(object sender, EventArgs e)
        {
            evlform evlform = new evlform();
            string zyh = dataGridView1.Rows[xh].Cells[0].Value.ToString();
            string tb = "select question,all_id from evaluate_question where case_id ='" + zyh + "' ";
            using (SqlConnection sql = new SqlConnection(zifuc))
            {
                sql.Open();
                SqlCommand one = sql.CreateCommand();
                one.CommandText = tb;
                SqlDataReader dr = one.ExecuteReader();
                if (dr.Read() == true)
                {
                    evl_allid = dr[1].ToString();
                    evl_question = dr[0].ToString();
                }
                else
                {
                    evl_allid = "";
                    evl_question = "";
                }
                sql.Close();
            }
            evlform.ShowDialog();
        }

        private void button25_Click(object sender, EventArgs e)
        {
            string zyh = dataGridView1.Rows[xh].Cells[0].Value.ToString();
            Form3 form3 = new Form3(zyh);
            form3.Show();
        }

        private void button46_Click(object sender, EventArgs e)
        {
            DianZiYaoLi yaoli = new DianZiYaoLi();
            yaoli.toolStripButton1.Enabled = false;
            yaoli.ShowDialog();
            dept01 = dept_name;//权限名赋值到电子药历窗口
        }

        private void button26_Click(object sender, EventArgs e)
        {
            string zyh = dataGridView1.Rows[xh].Cells[0].Value.ToString();
            Form4 form4 = new Form4(zyh, zhuangtai);
            form4.ShowDialog();
        }

        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DangQianHang.aa = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            jianyanxiagnxi.ShowDialog();
        }

        private void button45_Click(object sender, EventArgs e)
        {
            dcb dc = new dcb();
            dc.xb = label62.Text;
            dc.nl = label64.Text;
            dc.tz = label66.Text;
            dc.rysj = label73.Text;
            dc.cysj = label74.Text;
            shmc = dataGridView19.Rows[0].Cells[0].Value.ToString();
            qklx = dataGridView19.Rows[0].Cells[3].Value.ToString();
            rysj1 = label73.Text;
            cysj1 = label74.Text;
            blh = label60.Text;
            cyzd = label79.Text;
            ssks01 = label75.Text;
            dept01 = dept_name;//权限名赋值
            dc.ShowDialog();
        }
        private void dataGridView3_Click(object sender, EventArgs e)
        {
            Form5 f5 = new Form5((DataGridViewTextBoxColumn)dataGridView3.Columns[dataGridView3.CurrentCell.ColumnIndex]);
            f5.ShowDialog();
            ((DataGridViewTextBoxColumn)dataGridView3.Columns[dataGridView3.CurrentCell.ColumnIndex]).Width = num;
        }

        private void button29_Click(object sender, EventArgs e)
        {
            SaveAs(dataGridView11);
        }
        private void SaveAs(DataGridView a) //另存新档按钮   导出成Excel
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Execl files (*.xls)|*.xls";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.CreatePrompt = true;
            saveFileDialog.Title = "Export Excel File To";
            saveFileDialog.ShowDialog();
            Stream myStream;
            myStream = saveFileDialog.OpenFile();
            //StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312"));
            StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0));
            string str = "";
            //写标题
            for (int i = 0; i < a.ColumnCount; i++)
            {
                if (i > 0)
                {
                    str += "\t";
                }
                str += a.Columns[i].HeaderText;
            }
            sw.WriteLine(str);
            //写内容
            for (int j = 0; j < a.Rows.Count; j++)
            {
                string tempStr = "";
                for (int k = 0; k < a.Columns.Count; k++)
                {
                    if (k > 0)
                    {
                        tempStr += "\t";
                    }
                    tempStr += a.Rows[j].Cells[k].Value.ToString();
                }
                sw.WriteLine(tempStr);
            }
            sw.Close();
            myStream.Close();
        }
        
        private void tabPage26_Click(object sender, EventArgs e)
        {
            
        }

        private void tabControl1_Click(object sender, EventArgs e)
        {
           
        }

        private void tabPage25_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("fuck");
;
        }

        private void button30_Click(object sender, EventArgs e)
        {
            try
            {
                this.dataGridView11.Focus();
                if (dataGridView11.CurrentRow.Index + 1 < dataGridView11.Rows.Count)
                {
                    dataGridView11.CurrentCell = dataGridView11[0, dataGridView11.CurrentRow.Index + 1];
                }
            }
            catch
            {
                return;
            }

        }

        private void button31_Click(object sender, EventArgs e)
        {
            try
            {
                this.dataGridView11.Focus();
                if (dataGridView11.CurrentRow.Index - 1 >0)
                {
                    dataGridView11.CurrentCell = dataGridView11[0, dataGridView11.CurrentRow.Index - 1];
                }
            }
            catch
            {
                return;
            }
        }

        private void radioButton35_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton35, dataGridView3, "exec [Get_pt_orders]'");
        }

        private void shaixuanyizhu(RadioButton a,DataGridView b,string c)
        {
            if (a.Checked)
            {
                string case_id = (string)eny[xh];
                string cmdText4 = c + case_id + "','Mz'";
                string cmdText5 = c + case_id + "','Zy'";
                SqlConnection con1 = new SqlConnection(SQL.constr);
                con1.Open();
                if (case_id.Remove(2) == "Mz")
                {
                    SqlDataAdapter da3 = new SqlDataAdapter(cmdText4, con1);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3);
                    b.DataSource = ds3.Tables[0].DefaultView;

                }
                else if (case_id.Remove(2) == "Zy")
                {
                    SqlDataAdapter da4 = new SqlDataAdapter(cmdText5, con1);
                    DataSet ds4 = new DataSet();
                    da4.Fill(ds4);
                    b.DataSource = ds4.Tables[0].DefaultView;
                }
                con1.Close();
            }
        }

        private void radioButton36_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton36, dataGridView3,"exec [Get_pt_orders_drug]'");
        }

        private void radioButton37_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton37, dataGridView3, "exec [Get_pt_orders_kjy]'");
        }

        private void button48_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.DialogResult dr;
            dr = MessageBox.Show(this, "确定要退出系统吗", "提示：", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                this.Close();
                denglu dl = new denglu();
                dl.ShowDialog();
            }
            else
            {
                return;
            }
        }

        private void button47_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.DialogResult dr;
            dr = MessageBox.Show(this, "确定要锁定系统吗", "提示：", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                frmLock flock = new frmLock();
                this.Hide();
                flock.Show();
                flock.hide_Main += new frmLock.traseferdate(flock_hide_main);
            }
            else
            {
                return;
            }
            
        }

        private void textBox9_TextChanged(object sender, EventArgs e)
        {
            if (textBox9.Text != "")
            {
                textBox10.Enabled = false;
                panel20.Enabled = false;
            }
            else
            {
                textBox10.Enabled = true;
                panel20.Enabled = true;
            }
        }

        private void textBox10_TextChanged(object sender, EventArgs e)
        {
            if (textBox10.Text != "")
            {
                textBox9.Enabled = false;
            }
            else
            {
                textBox9.Enabled = true; ;
            }
        }

        private void radioButton40_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton40, dataGridView16, "exec [Get_pt_orders]'");
        }

        private void radioButton39_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton40, dataGridView16, "exec [Get_pt_orders_drug]'");
        }

        private void radioButton38_CheckedChanged(object sender, EventArgs e)
        {
            shaixuanyizhu(radioButton40, dataGridView16, "exec [Get_pt_orders_kjy]'");
        }

        private void dataGridView17_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DangQianHang.aa = dataGridView17.Rows[dataGridView17.CurrentRow.Index].Cells[0].Value.ToString().Trim();//获取当前选中的列。第一列
            DangQianHang.bb = dataGridView17.Rows[dataGridView17.CurrentRow.Index].Cells[1].Value.ToString().Trim();//获取当前选中的列。第二列
            Form jianyanxiagnxi = new JianYanXiangXiJieGuo();
            jianyanxiagnxi.ShowDialog();
        }

        //选择合理
        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton5.Checked)
            {
                richTextBox13.Text = "";
                checkBox19.Checked = false; checkBox21.Checked = false; checkBox23.Checked = false; checkBox30.Checked = false; checkBox51.Checked = false;
                checkBox21.Checked = false; checkBox24.Checked = false; checkBox26.Checked = false; checkBox29.Checked = false; checkBox33.Checked = false;
                checkBox34.Checked = false; checkBox35.Checked = false; checkBox36.Checked = false; checkBox37.Checked = false; checkBox38.Checked = false;
                checkBox39.Checked = false; checkBox40.Checked = false; checkBox41.Checked = false; checkBox42.Checked = false; checkBox46.Checked = false;
                checkBox47.Checked = false; checkBox48.Checked = false; checkBox49.Checked = false; checkBox43.Checked = false; checkBox44.Checked = false;
                panel10.Enabled = false;
            }
        }
        //选择不合理
        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton6.Checked)
            {
                panel10.Enabled = true;
            }
        }
        //checkBox排斥 26/29
        private void checkBox26_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox26.Checked)
            {
                checkBox29.Checked = false;
            }
        }
        //37/38/39
        private void checkBox29_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox29.Checked)
            {
                checkBox26.Checked = false;
            }
        }
        //37/38/39
        private void checkBox37_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox37.Checked)
            {
                checkBox38.Checked = false;
                checkBox39.Checked = false;
            }
        }

        private void checkBox38_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox38.Checked)
            {
                checkBox37.Checked = false;
                checkBox39.Checked = false;
            }
        }

        private void checkBox39_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox39.Checked)
            {
                checkBox38.Checked = false;
                checkBox37.Checked = false;
            }
        }
        //46/47/48/49
        private void checkBox46_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox46.Checked)
            {
                checkBox47.Checked = false;
                checkBox48.Checked = false;
                checkBox49.Checked = false;
            }
        }

        private void checkBox47_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox47.Checked)
            {
                checkBox46.Checked = false;
                checkBox48.Checked = false;
                checkBox49.Checked = false;
            }
        }

        private void checkBox48_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox48.Checked)
            {
                checkBox47.Checked = false;
                checkBox46.Checked = false;
                checkBox49.Checked = false;
            }
        }

        private void checkBox49_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox49.Checked)
            {
                checkBox47.Checked = false;
                checkBox48.Checked = false;
                checkBox46.Checked = false;
            }
        }


    }
}

            
                
                
                
                
 


